kit
kit copied to clipboard
enable suggestions for generated types `./$types`
Adds a path to the generated tsconfig.json
file to resolve an import to .svelte-kit/types/src/routes/$types
as ./$types
.
Adding this path fixes a slight issue I've had with generated types where Quick Fix does not include './$types'
as a suggestion.
Before:
After:
Sorry if this is unnecessary or implemented incorrectly. This is my first time submitting a PR.
Also, I tried to find a more variable that would lead to .svelte-kit/types/src/routes/
but the best I could find was config.outDir
for .svelte-kit
. Would appreciate if anyone knew a better path variable to use.
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
- [x] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it.
Tests
- [x] Run the tests with
pnpm test
and lint the project withpnpm lint
andpnpm 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 bepatch
until SvelteKit 1.0
⚠️ No Changeset found
Latest commit: a5747ae69ef78a37f7685b16b9f84370ded9c767
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
What do I have to do to get this to work? It's not showing up as a Quick Fix option for me:

What do I have to do to get this to work? It's not showing up as a Quick Fix option for me:
![]()
The original paths that I used when testing this are as below.
"./types": [".svelte-kit/types/src/routes/$types", ".svelte-kit/types/src/routes/*/$types"],
Not sure if the config.outDir
I used to replace the static path with is causing it to not work.
However, I've discovered that the generated types full path import does not show as a Quick Fix option in any files unless there's at least one import statement in a file referencing $types.
This also means TypeScript won't recognise the ./$types
alias as it relies on the generated types existing and being added by TypeScript to the file watch.
Is it possible to get TypeScript to recognise the generated types without having to manually add the first import?
Closing this, this was fixed inside TypeScript itself. I'm not sure which version this lands in, but either next month or in 4 months it'll work as expected.