nuxt-typed-router icon indicating copy to clipboard operation
nuxt-typed-router copied to clipboard

Support overriden route names (through definePageMeta)

Open ChronicStone opened this issue 1 year ago • 6 comments

It looks like the generated types definition does not take into account overriding of route name using definePageMeta. Here's an actual example :


// DEFAULT PAGE NAME SHOULD BE "testCenter-candidates-candidateId" HERE

definePageMeta({
  name: "testCenter-candidates-profile",
});

navigateTo({ name: "testCenter-candidates-candidateId", params: { candidateId: "hjzez" } });
// VALID NAME, even though the name has been overridden

navigateTo({ name: "testCenter-candidates-profile", params: { candidateId: "hjzez" } });
/*  No overload matches this call.
  Overload 1 of 2, '(to: TypedRouteLocationRawFromName<RoutesNamesList, string>, options?: NavigateToOptions | undefined): Promise<...>', gave the following error.
  Overload 2 of 2, '(to: string, options?: NavigateToOptions | undefined): Promise<void | NavigationFailure | TypedRouteFromName<never>>', gave the following error.ts(2769)

*/

Is this an actual limitation, or something that can be addressed ?

ChronicStone avatar Mar 28 '23 18:03 ChronicStone