Skip to content

Typed routes out of the box (without file based routing) #2494

Open
@ThomasKientz

Description

@ThomasKientz

What problem is this solving

Navigate to an unknown route isn't catch by typescript.

export const router = createRouter({
  routes: [
    { path: "/foo", component: () => import("./pages/foo.vue") },
  ],
  history: createWebHistory(),
});

router.push("/bar"); // <------ No type error

Proposed solution

Infer types so router is strongly typed with declared routes.

Describe alternatives you've considered

unplugin-vue-router but its file based routing.

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