Skip to content

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Aug 13, 2025

This resolves the "ignore me TS, this module will be available later"-hack we did in #13864: Instead of ts-ignoring the $app/types import, we now generate that in advance. We didn't do that previously because there's no way to do declaration merging with types - but you can do it with interfaces, so instead we now have an interface whose properties we declaration-merge, and the types just forward those. The wrinkle is that we cannot make the properties be the types directly, else you get a "not the same types" error. Instead we're using functions because they are merged into overloads.

For this to properly work across tests (not polluting each other) I had to adjust the test infrastructure a bit, now each test project is run separately. Sadly that means it takes longer, not sure why tsc is so slow here.

Will take another look at this with a fresh pair of eyes tomorrow for the type check failure.


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. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

This resolves the "ignore me TS, this module will be available later"-hack we did in #13864: Instead of ts-ignoring the `$app/types` import, we now generate that in advance. We didn't do that previously because there's no way to do declaration merging with types - but you can do it with interfaces, so instead we now have an interface whose properties we declaration-merge, and the types just forward those. The wrinkle is that we cannot make the properties be the types directly, else you get a "not the same types" error. Instead we're using functions because they are merged into overloads.

For this to properly work across tests (not polluting each other) I had to adjust the test infrastructure a bit, now each test project is run separately. Sadly that means it takes longer, not sure why `tsc` is so slow here.
Copy link

changeset-bot bot commented Aug 13, 2025

🦋 Changeset detected

Latest commit: 6fd8cf8

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

@svelte-docs-bot
Copy link

@dummdidumm dummdidumm marked this pull request as ready for review August 14, 2025 10:08
Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creates a branch called 'app-types-without-hacks'

opens a PR with the most brilliant hack I've seen in my life

@dummdidumm dummdidumm merged commit ea95533 into main Aug 14, 2025
21 checks passed
@dummdidumm dummdidumm deleted the app-types-without-hacks branch August 14, 2025 14:16
@github-actions github-actions bot mentioned this pull request Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants