sveltejs / sveltejs/kit

`$page.params` typed?

Open
#12,083 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting submitter
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

Hi great people!

Sometimes it happens I forget to change code I copy from other files and I do not get errors if the params are wrong:

Example in src/routes/players/[player_id]/+page.svelte, this is wrong:

playerId={$page.params.team_id}

it should be:

playerId={$page.params.player_id}

Is there a way to make the compiler shout that that param is wrong in that place?

Describe the proposed solution

I don't really know.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/routes/players/[player_id]/+page.svelte and inspect how $page.params is typed there. The change is done when the compiler rejects team_id in this route while accepting player_id, with the behavior covered by an appropriate test or example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.