What versions & operating system are you using?
wrangler. 4.20.5, node.js 23.11.1, macos and linux (CI pipeline OS)
Please provide a link to a minimal reproduction
https://github.com/Kjaer/wrangler-kv-namespace-type-problem
Describe the Bug
I have following wrangler.toml file:
name = "my-worker"
main = "src/index.ts"
upload_source_maps = true
account_id = "xxxxxxxxxxxx"
compatibility_date = "2025-04-01"
compatibility_flags = ["nodejs_compat", "nodejs_compat_populate_process_env"]
[env.feature]
name = "my-worker-feature"
[[env.feature.kv_namespaces]]
binding = "MY_STORAGE_FEATURE"
id = "xxxxxxxxxxxx
[env.feature.vars]
DEPLOY_ENV = "feature"
SPACE_ID = "xxxxxxx"
ENVIRONMENT = "feature-environment"
FETCH_ENTRY_LIMIT = 1000
CACHE_DEFAULT_TTL_SECONDS = 3600
And I have similar 3 different environments in my wrangler.toml file too.
When I ran npx wrangler types it perfectly creates type definitions for environment variables. But it cannot create type definitions for KV Namespaces.
So I had to repeat KV Namespaces information on root level like this:
name = "my-worker"
main = "src/index.ts"
upload_source_maps = true
account_id = "xxxxxxxxxxxx"
compatibility_date = "2025-04-01"
compatibility_flags = ["nodejs_compat", "nodejs_compat_populate_process_env"]
[[kv_namespaces]]
binding = "MY_STORAGE_FEATURE"
id = "xxxxxxxxxxxx
[env.feature]
name = "my-worker-feature"
[[env.feature.kv_namespaces]]
binding = "MY_STORAGE_FEATURE"
id = "xxxxxxxxxxxx
[env.feature.vars]
DEPLOY_ENV = "feature"
SPACE_ID = "xxxxxxx"
ENVIRONMENT = "feature-environment"
FETCH_ENTRY_LIMIT = 1000
CACHE_DEFAULT_TTL_SECONDS = 3600
now npx wrangler types create type definitions for my KV namespaces. Eventhough I am getting warnings during deployment it still works. Yet this is not usual.
Please provide any relevant error logs
No response
What versions & operating system are you using?
wrangler. 4.20.5, node.js 23.11.1, macos and linux (CI pipeline OS)
Please provide a link to a minimal reproduction
https://github.com/Kjaer/wrangler-kv-namespace-type-problem
Describe the Bug
I have following
wrangler.tomlfile:And I have similar 3 different environments in my
wrangler.tomlfile too.When I ran
npx wrangler typesit perfectly creates type definitions for environment variables. But it cannot create type definitions for KV Namespaces.So I had to repeat KV Namespaces information on root level like this:
now
npx wrangler typescreate type definitions for my KV namespaces. Eventhough I am getting warnings during deployment it still works. Yet this is not usual.Please provide any relevant error logs
No response