🐛 The bug
@nuxtjs/robots augments NitroRouteRules and NitroRouteConfig only on declare module 'nitropack'. The Nuxt config type system resolves route rules through 'nitropack/types', so declaring a robots rule in routeRules fails with TS2353.
The generated .nuxt/types/nuxt-robots-nitro.d.ts shows the gap.
declare module 'nitropack' {
interface NitroRouteRules { robots?: RobotsValue | { indexable: boolean, rule: string } }
interface NitroRouteConfig { robots?: RobotsValue | { indexable: boolean, rule: string } }
}
// No matching `declare module 'nitropack/types'` block.
Sibling Nuxt SEO modules (@nuxtjs/sitemap, nuxt-og-image, nuxt-security) augment both specifiers. Only robots is missing the second one.
🛠️ To reproduce
StackBlitz: https://stackblitz.com/github/JonathanXDR/repro-nuxtjs-robots-routerules
A minimal Nuxt 4 project. StackBlitz runs npm run typecheck on boot and produces:
nuxt.config.ts(10,7): error TS2353: Object literal may only specify known properties,
and 'robots' does not exist in type '{ cache?: ... }'.
robots: false,
🌈 Expected behavior
robots should be a known property on NitroRouteRules and NitroRouteConfig when resolved through either 'nitropack' or 'nitropack/types', matching how @nuxtjs/sitemap, nuxt-og-image, and nuxt-security already work. No shim should be needed in user projects.
Suggested fix: mirror the existing declare module 'nitropack' block with an identical declare module 'nitropack/types' block in the generated .d.ts (see .nuxt/types/nuxt-sitemap-augments.d.ts for the pattern).
ℹ️ Additional context
|
|
| Operating system |
macOS 25.5.0 |
| CPU |
Apple M4 Pro (14 cores) |
| Node.js version |
v26.0.0 |
| nuxt/cli version |
3.35.2 |
| Package manager |
npm@11.12.1 |
| Nuxt version |
4.4.6 |
| Nitro version |
2.13.4 |
| Builder |
vite@7.3.3 |
| Config |
compatibilityDate, modules, routeRules, typescript |
| Modules |
@nuxtjs/robots@6.0.8 |
🐛 The bug
@nuxtjs/robotsaugmentsNitroRouteRulesandNitroRouteConfigonly ondeclare module 'nitropack'. The Nuxt config type system resolves route rules through'nitropack/types', so declaring arobotsrule inrouteRulesfails with TS2353.The generated
.nuxt/types/nuxt-robots-nitro.d.tsshows the gap.Sibling Nuxt SEO modules (
@nuxtjs/sitemap,nuxt-og-image,nuxt-security) augment both specifiers. Only robots is missing the second one.🛠️ To reproduce
StackBlitz: https://stackblitz.com/github/JonathanXDR/repro-nuxtjs-robots-routerules
A minimal Nuxt 4 project. StackBlitz runs
npm run typecheckon boot and produces:🌈 Expected behavior
robotsshould be a known property onNitroRouteRulesandNitroRouteConfigwhen resolved through either'nitropack'or'nitropack/types', matching how@nuxtjs/sitemap,nuxt-og-image, andnuxt-securityalready work. No shim should be needed in user projects.Suggested fix: mirror the existing
declare module 'nitropack'block with an identicaldeclare module 'nitropack/types'block in the generated.d.ts(see.nuxt/types/nuxt-sitemap-augments.d.tsfor the pattern).ℹ️ Additional context
macOS 25.5.0Apple M4 Pro (14 cores)v26.0.03.35.2npm@11.12.14.4.62.13.4vite@7.3.3compatibilityDate,modules,routeRules,typescript@nuxtjs/robots@6.0.8