AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Next.Js 16.3.0+ Published Types Break TypeScript <6 Due To Missing URLPatternInput/URLPatternOptions Names

Since Next.js 16.3.0, the published .d.ts files reference global type names URLPatternInput, URLPatternOptions, and URLPattern generic parameters that are only available in TypeScript 6.0+. This causes TypeScript 5.x users with skipLibCheck: false to encounter TS2304 errors in next/dist/server/web/spec-extension/url-pattern.d.ts, breaking typechecking for any project that types its next.config.ts.

highConfidence 95%Next.jsAffected V16.3.0Affected V16.4.0-Canary.58

Origin Analysis

Next.js is now built with TypeScript 6, which infers and embeds generic type parameters (URLPatternInput, URLPatternOptions) into the generated declaration for GlobalURLPattern. These names are not present in TypeScript 5.x's lib.dom or @types/node, so they resolve as unknown, producing compilation errors.
1. Create a Next.js project with next >= 16.3.0 and TypeScript 5.9.3. 2. Add a typed next.config.ts file. 3. Set skipLibCheck: false in tsconfig.json. 4. Run tsc --noEmit (or npm run typecheck). 5. Observe 7 errors from node_modules/next/dist/server/web/spec-extension/url-pattern.d.ts regarding missing URLPatternInput, URLPatternOptions, and URLPattern.

Fixing Code Block

Edge Case Audit

This fix assumes that `globalThis.URLPattern` exists in the target environment's TypeScript DOM library. If URLPattern is not defined at all (e.g., very old TypeScript or missing DOM lib), the type becomes `any`, which may mask real type errors. Patching node_modules directly is not persistent across reinstalls; use patch-package or wait for an official Next.js release. Rollback: revert to next@16.2.0 or temporarily set skipLibCheck: true to suppress the error until an official fix is published.

Ecosystem Topology