next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Value returned from `generateSitemaps` is received as a string instead of number

Open therungg opened this issue 2 weeks ago • 1 comments

Link to the code that reproduces this issue

https://github.com/therungg/next-sitemap-generation-typing-bug

To Reproduce

  1. Create a sitemap as per the docs https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps#example
  2. await the id in the sitemap function
  3. The id is actually a string, not a number

Current vs. Expected behavior

The id received in the sitemap function is actually a string, not a number as the type indicates. I expect it to be a number.

This means that, for example, doing a switch case over the id does not work, because it never matches the number in the switch case. See reproduction repo for minimal repro

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 8937
  Available CPU cores: 16
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.0.0
Relevant Packages:
  next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

therungg avatar Dec 09 '25 00:12 therungg

I can take a look at this.

The id value passed to generateSitemaps() is coming through as a string, but the TypeScript type declares it as a number. The runtime behavior and type definitions are inconsistent.

I’ll update the type in the sitemap types to match the actual value.

azadgupta1 avatar Dec 09 '25 00:12 azadgupta1

We fixed the docs. Promise is a wider, better indication, that matches what the framework ends up passing.

We don't have yet prop type helpers for these, otherwise these would've catch this. Thanks for the report and time to create a repository.

icyJoseph avatar Dec 09 '25 12:12 icyJoseph