Skip to content

Optional route params do not play well with exactOptionalPropertyTypes #15453

@Stadly

Description

@Stadly

Describe the bug

In RouteParams, optional route parameters are typed as { param?: string }. This does not work well when using exactOptionalPropertyTypes, since TypeScript will yell if you pass in undefined:

Image

The solution is to type optional parameters as { param?: string | undefined }.

Reproduction

Create a SvelteKit app with a route with an optional route parameter. Use the resolve function and try passing in undefined to the route parameter.

Logs

System Info

N/A

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions