workers-types
workers-types copied to clipboard
module worker typings support
Module worker syntax is currently not supported by @cloudflare/workers-types.
This means that users don't get the benefits of autocompletion or type checking when they use the new syntax.
References:
- https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-module-worker
- https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/#syntax-module-worker
- https://unpkg.com/browse/@cloudflare/[email protected]/index.d.ts
Module Worker type should be here: https://github.com/cloudflare/workers-types/blob/master/index.d.ts#L553-L556
FWIW, I get full types when I declare my Module worker this way -
// worker.ts
const workerHandler: ExportedHandler = {
async fetch(req, env, ctx) {
return new Response("hello");
},
};
export default workerHandler;