Skip to content

Generated enum type for routeId #6167

@Conduitry

Description

@Conduitry

Describe the problem

$page.routeId is just a string currently, which means you can have typos that won't match the ID of any route. It would be nice if this were typed, so that typos will be caught as type errors, and so that any renamed pages or moved routes will also result in type errors if their corresponding $page.routeIds aren't also updated.

Describe the proposed solution

We know the route manifest at build time. We should be able to construct a 'foo' | 'bar' | 'baz' type that the routeId would adhere to. The question would be where this generated type ought to live and how it ought to be accessed by the app code. Ideally, people could just keep using the ambient $app/stores types, and these would pull in the appropriate enum from .svelte-kit.

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature / enhancementNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.types / typescript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions