Skip to content

Generate types for paths #7110

@AlexRMU

Description

@AlexRMU

Describe the problem

  • Consider the base variable
  • Consider other paths on the same site, but outside of kit (special type in App?)
  • Consider external links
  • Slugs types need to be taken from params
  • Consider hash, parameters, different protocols
  • Use these types in kit wherever possible (redirect, load params, ...)

Example:

/*
existing paths:
[
    "/",
    "/blog",
    "/blog/post/[post]",
    "/blog/tag/[tag=integer]",
    "/shop/[...slugs]",
]
*/

throw redirect(301, "/");
throw redirect(301, "/blog");
throw redirect(301, "/blog/qwe"); //type error
throw redirect(301, "/blog/post"); //type error
throw redirect(301, "/blog/post/qwe");
throw redirect(301, "/blog/tag/1");
throw redirect(301, "/blog/tag/qwe"); //type error
throw redirect(301, "/shop"); //type error
throw redirect(301, "/shop/a/b/c");
throw redirect(301, "https://www.google.com");
throw redirect(301, "/qwe"); //external

Describe the proposed solution

It is interesting:

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions