Type generation extensibility 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
I want to create additional generated types like RequestEvent per route.
Describe the proposed solution
Something here
That runs my own configured definition factories, the signature taking routes, route (and perhaps config, although why?) to append to declarations to be emitted when sveltekit types are generated
fn addDefinition({routes, route}) => {imports, declarations, exports} run and append them here
Maybe it could pick up a magic function from somewhere? Maybe a file that exists along the route directory structure? Falling back to tthe magic file at root or /app.
Alternatives considered
Script that runs and appends to each $types.d.ts after svelte has generated its types (unreliable)
Importance
would make my life easier
Additional Information
Allowing modification of core types is out of scope (probably not recommended at all?)
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 in packages/kit/src/core/sync/write_types/index.js at the referenced lines, and trace how route types and declarations are assembled. Clarify the hook location, configuration or magic-file discovery, and the definition-factory contract; done means configured per-route types such as RequestEvent are emitted without post-generation scripts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100