TypeScript
TypeScript is a first-class language on Cloudflare Workers. Cloudflare publishes type definitions to GitHub and npm (npm install -D @cloudflare/workers-types
). All APIs provided in Workers are fully typed, and type definitions are generated directly from workerd, the open-source Workers runtime.
Known issues
Transitive loading of @types/node
overrides `@cloudflare/workers-types
You project’s dependencies may load the @types/node
package on their own. As of @types/node@20.8.4
that package now overrides Request
, Response
and fetch
types (possibly others) specified by @cloudflare/workers-types
causing type errors.
The way to get around this issue currently is to pin the version of @types/node
to 20.8.3
in your package.json
like this:
package.json{ "overrides": { "@types/node": "20.8.3" }
}
For more information, refer to this GitHub issue.