-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Astro.params has a wrong type #14057
Copy link
Copy link
Closed
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: typescriptRelated to TypeScript (scope)Related to TypeScript (scope)requires breaking changeFixing this bug or adding this feature would require breaking changes. For PRs, use "semver: major"Fixing this bug or adding this feature would require breaking changes. For PRs, use "semver: major"
Milestone
Description
Astro Info
Astro v5.11.0
Node v24.3.0
System Linux (x64)
Package Manager pnpm
Output static
Adapter none
Integrations @astrojs/svelte
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Astro.params has a wrong type. For example:
export function getStaticPaths() {
return [
{ params: { id: '1' } },
];
}
const { id } = Astro.params;The IDE / TypeScript says id is a Number, but it’s actually a string.
What's the expected result?
TypeScript should infer the correct type. In this case, id should either be typed as a string or Astro.params.id should behave correctly and actually be a Number.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-uqia3qvx?file=src%2Fpages%2F%5Bid%5D.astro
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: typescriptRelated to TypeScript (scope)Related to TypeScript (scope)requires breaking changeFixing this bug or adding this feature would require breaking changes. For PRs, use "semver: major"Fixing this bug or adding this feature would require breaking changes. For PRs, use "semver: major"