Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guarantee that $page.route has the correct shape #8359

Merged
merged 3 commits into from Jan 6, 2023
Merged

Conversation

Rich-Harris
Copy link
Member

fixes #8351. This bug was made possible by lazy typing, so rather than add a new test (since we really need to figure out a way to reduce our reliance on e2e tests) I made the types stricter instead.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2023

🦋 Changeset detected

Latest commit: dc14520

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Conduitry
Copy link
Member

Is this the shape we want? To me this seems a little bit similar to the event.platform issue where it was decided that event.platform itself could be undefined, not an empty object. What's the justification for saying that event.platform might be undefined but page.route isn't?

@Rich-Harris
Copy link
Member Author

page.route is always defined, but sometimes its id is null

@Rich-Harris
Copy link
Member Author

ah wait, I understand what you're saying. err... i don't recall the justification for this, but i do remember us discussing it and landing on this

@Conduitry
Copy link
Member

That's fine, I just wanted to bring this up. I'll trust your memory of some previous discussions about this.

@dummdidumm
Copy link
Member

We did discuss it and one of the reasons we landed on it was that writing route?.id instead of route.id (and therefore crashing at runtime sometimes) is probably an easy mistake to make.

@Rich-Harris
Copy link
Member Author

cool, will go ahead and merge this

@Rich-Harris Rich-Harris merged commit 4ff91b0 into master Jan 6, 2023
@Rich-Harris Rich-Harris deleted the gh-8351 branch January 6, 2023 14:42
This was referenced Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$page.route is null on error page
3 participants