fwiw if you don't want to have to declare `Environment` for every handler, you can type the `export

fwiw if you don't want to have to declare Environment for every handler, you can type the export default object literal

interface Environment {
  TOP_SECRET: string
}

interface Message {
  MY_EPIC_QUEUE_MESSAGE_INTERFACE_OR_WHATEVER: string
}

export default <ExportedHandler<Environment, Message>> {
  async fetch(req, env, ctx) {
    return new Response();
  },
  async queue(msg, env, ctx) {
    // do stuff
  }
}
Was this page helpful?