CLI Feature: "svelte-kit sync" or "@sveltejs/kit/src/core/sync/write_types" hooks
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
There is no way to cleanly modify the types generated by @sveltejs/kit/src/core/sync/write_types/index.js
(example: .svelte-kit/types/src/routes/.../$types.d.ts)
Describe the proposed solution
Add a pipe hook in svelte.config.ts that user can use to rewrite the types before they get saved
Alternatives considered
Waiting for the types to generate then overwriting it, but this forces ide to do a lot of tsconfig recalculations which will cause unnecessary performance issues and general confusion while the types recalculate
Importance
i cannot use SvelteKit without it
Additional Information
I faced this issue while working on https://github.com/SaaSTEMLY/sveltekit-auto-openapi, I wanted to extend RequestEvent to contain types that are generated "magically" from a _config object above it without having to wrap it with a boilerplate helper function
Currently Im using the alternative of "waiting until the types generate and then overriting it", but this makes my IDE flash with different types everytime I save which is bad developer experience, and the problem would get worse the more files that generate at once, example running vite dev triggers sveltekit to rewrite all the types, so I have to overwrite all the types again right after user runs vite dev
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading @sveltejs/kit/src/core/sync/write_types/index.js and the svelte.config.ts configuration mentioned in the issue. Trace how .svelte-kit/types/src/routes/.../$types.d.ts files are generated and identify where a hook could rewrite them before saving. Done means users can transform generated types through configuration without a later overwrite or repeated IDE recalculation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100