Skip to content

CLI Feature: "svelte-kit sync" or "@sveltejs/kit/src/core/sync/write_types" hooks #15093

@MahmoodKhalil57

Description

@MahmoodKhalil57

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions