Environment
- Operating System: macOS
- Node Version: v22
- Nitro Version: nightly (3.x)
- Package Manager: pnpm
- Preset:
cloudflare_module
Reproduction
- Create a Nitro project with
preset: 'cloudflare_module' and a custom runtimeConfig
- Run
nitro dev
- Stop the dev server
- Run
tsc --noEmit
Describe the bug
The Cloudflare dev preset (src/presets/cloudflare/dev.ts) injects a wrangler key into runtimeConfig at module installation time to share Miniflare configuration (config path, persist dir, environment) with the runtime plugin.
However, this internal key is not filtered out during type generation in src/build/types.ts. The existing filter only excludes app and nitro:
Object.entries(nitro.options.runtimeConfig).filter(
([key]) => !["app", "nitro"].includes(key)
)
This causes wrangler to appear in the generated NitroRuntimeConfig interface (node_modules/.nitro/types/nitro-config.d.ts):
interface NitroRuntimeConfig {
// ... user-defined keys ...
wrangler: {
configPath: string,
persistDir: string,
environment: any,
},
}
Which produces a type error in nitro.config.ts because wrangler is a required property that the user never defined.
The fix is straightforward: add "wrangler" to the exclusion list in src/build/types.ts alongside "app" and "nitro". I'll open a PR with the fix.
Additional context
Running nitro prepare alone does not trigger the issue because the Cloudflare dev module only runs during nitro dev. But once the dev server has run, the generated types persist in node_modules/.nitro/types/nitro-config.d.ts and cause tsc to fail.
Logs
nitro.config.ts(23,3): error TS2741: Property 'wrangler' is missing in type '{ api: { key: string; }; paddle: { apiKey: string; apiKeySandbox: string; webhookSecret: string; webhookSecretSandbox: string; }; magicLink: { secret: string; }; resend: { apiKey: string; from: string; }; }' but required in type 'NitroRuntimeConfig'.
Environment
cloudflare_moduleReproduction
preset: 'cloudflare_module'and a customruntimeConfignitro devtsc --noEmitDescribe the bug
The Cloudflare dev preset (
src/presets/cloudflare/dev.ts) injects awranglerkey intoruntimeConfigat module installation time to share Miniflare configuration (config path, persist dir, environment) with the runtime plugin.However, this internal key is not filtered out during type generation in
src/build/types.ts. The existing filter only excludesappandnitro:This causes
wranglerto appear in the generatedNitroRuntimeConfiginterface (node_modules/.nitro/types/nitro-config.d.ts):Which produces a type error in
nitro.config.tsbecausewrangleris a required property that the user never defined.The fix is straightforward: add
"wrangler"to the exclusion list insrc/build/types.tsalongside"app"and"nitro". I'll open a PR with the fix.Additional context
Running
nitro preparealone does not trigger the issue because the Cloudflare dev module only runs duringnitro dev. But once the dev server has run, the generated types persist innode_modules/.nitro/types/nitro-config.d.tsand causetscto fail.Logs