workers-types icon indicating copy to clipboard operation
workers-types copied to clipboard

module worker typings support

Open IgorMinar opened this issue 3 years ago • 2 comments

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

IgorMinar avatar Mar 22 '22 19:03 IgorMinar

Module Worker type should be here: https://github.com/cloudflare/workers-types/blob/master/index.d.ts#L553-L556

GregBrimble avatar Mar 22 '22 19:03 GregBrimble

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;

eugene1g avatar May 25 '22 20:05 eugene1g