

pnpm wrangler types be available as ambient types without needing to reference the types in each file? I am finding that they are not, and I have to use /// <reference path="../worker-configuration.d.ts" /> at the top of the file for them to work. My tsconfig, in case I'm misconfiguring:compilerOptions.types and not in include.wrangler types (as described in https://developers.cloudflare.com/workers/languages/typescript/)TypeError: The RPC receiver does not implement the method "getFoo".?


wrangler types. I'm personally not a big fan of it, but it's where things seem to be moving. I believe it causes more problems than what it sets out to solve - such as no nodejs_compat, interop with libraries that do need to import from workers-types and now ending up with duplicate types, etc. so in all of my projects I'm still using workers-types and defining my Env manually.wrangler types is now wrangler types --include-runtime=false
--metafile flag to the wrangler CLI. This outputs esbuild's metafile, which can then be used to easily analyze your Cloudflare Worker's bundle size!npx wrangler deploy --dry-run --metafile=./meta.json && npx banal -M ./meta.json (or add to your package.json file as analyze).
cache-control: public, max-age=1, stale-while-revalidate=604800
cf-cache-status: UPDATINGpnpm wrangler types/// <reference path="../worker-configuration.d.ts" />compilerOptions.typesincludewrangler typeswrangler typeswrangler typesTypeError: The RPC receiver does not implement the method "getFoo".// api/wrangler.jsonc
"services": [{
"binding": "FOO_SERVICE",
"service": "my-services",
"entrypoint": "FooService"
},
{
"binding": "USERS_SERVICE",
"service": "my-services",
"entrypoint": "UsersService"
}]`// api/vitest.config.ts
export default defineWorkersProject(async () => {
return {
test: {
// … more setup
poolOptions: {
workers: {
wrangler: { configPath: `${__dirname}/wrangler.jsonc`, environment: 'test' },
singleWorker: true,
miniflare: {
bindings: {
TEST_MIGRATIONS: migrations,
TEST_SEED_FILES: seedFiles,
},
serviceBindings: {
USERS_SERVICE: { name: 'my-services', entrypoint: 'UsersService' },
FOO_SERVICE: { name: 'my-services', entryPoint: 'FooService' },
},
workers: [
{ // built by globalSetup.ts, coped into this directory
name: my-services',
modules: true,
scriptPath: './.test/workers/services/my_services/index.js',
compatibilityDate: '2025-01-01',
compatibilityFlags: ['nodejs_compat'],
},
],
},
},
},
},
};
});nodejs_compatworkers-typesworkers-typesEnvwrangler types --include-runtime=false--metafilenpx wrangler deploy --dry-run --metafile=./meta.json && npx banal -M ./meta.jsonanalyze{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.cloudflare.json"
}
],
"include": [
"worker-configuration.d.ts"
],
"compilerOptions": {
"checkJs": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"@/*": [
"./app/*"
]
}
}
}