Skip to content

Route rule augmentation missing on 'nitropack/types' causes TS2353 in nuxt config #299

@JonathanXDR

Description

@JonathanXDR

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions