From: Eduardo San Martin Morote Date: Mon, 10 Jun 2024 20:10:28 +0000 (+0200) Subject: refactor: remove old RouteRecordName X-Git-Tag: v4.4.0-alpha.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=274d2459d199353e2810f2bd2eef0d963f9bc463;p=thirdparty%2Fvuejs%2Frouter.git refactor: remove old RouteRecordName --- diff --git a/packages/router/__tests__/utils.ts b/packages/router/__tests__/utils.ts index 62f258b1..1d4e8132 100644 --- a/packages/router/__tests__/utils.ts +++ b/packages/router/__tests__/utils.ts @@ -4,7 +4,6 @@ import { MatcherLocation, RouteComponent, RouteRecordRaw, - RouteRecordName, _RouteRecordProps, } from '../src/types' import { h, ComponentOptions } from 'vue' @@ -65,7 +64,7 @@ export interface RouteRecordViewLoose // @ts-expect-error we are intentionally overriding the type export interface RouteLocationNormalizedLoose extends RouteLocationNormalized { - name: RouteRecordName | null | undefined + name: string | symbol | null | undefined path: string // record? params: any diff --git a/packages/router/src/matcher/index.ts b/packages/router/src/matcher/index.ts index 44f8a50e..b40a0b89 100644 --- a/packages/router/src/matcher/index.ts +++ b/packages/router/src/matcher/index.ts @@ -4,7 +4,6 @@ import { MatcherLocation, isRouteName, _RouteRecordProps, - RouteRecordName, } from '../types' import { createRouterError, ErrorTypes, MatcherError } from '../errors' import { createRouteRecordMatcher, RouteRecordMatcher } from './pathMatcher' @@ -20,6 +19,7 @@ import { comparePathParserScore } from './pathParserRanker' import { warn } from '../warning' import { assign, noop } from '../utils' +import type { RouteRecordName } from '../typed-routes' /** * Internal RouterMatcher diff --git a/packages/router/src/typed-routes/index.ts b/packages/router/src/typed-routes/index.ts index 08b32445..deff65da 100644 --- a/packages/router/src/typed-routes/index.ts +++ b/packages/router/src/typed-routes/index.ts @@ -8,7 +8,7 @@ export type { export type { RouteRecordInfo } from './route-map' export type { - _RouteRecordName as RouteRecordName, + RouteRecordName as RouteRecordName, _RouteLocationRaw as RouteLocationRaw, RouteLocation, _RouteLocationNormalized as RouteLocationNormalized, diff --git a/packages/router/src/typed-routes/route-location.ts b/packages/router/src/typed-routes/route-location.ts index c405388a..5f52ff9e 100644 --- a/packages/router/src/typed-routes/route-location.ts +++ b/packages/router/src/typed-routes/route-location.ts @@ -3,7 +3,6 @@ import type { RouteLocationNormalizedLoaded, RouteLocationOptions, RouteQueryAndHash, - RouteRecordName, RouteLocationRaw, _RouteLocationBase, } from '../types' @@ -14,9 +13,9 @@ import type { Router } from '../router' import type { RouteRecord } from '../matcher/types' /** - * Type safe version if it exists of the routes' names. + * Possible values for a user-defined route record's name */ -export type _RouteRecordName = keyof RouteMap +export type RouteRecordName = keyof RouteMap /** * Type safe version of the {@link RouteLocation} type. @@ -26,7 +25,7 @@ export interface RouteLocationTyped< RouteMap extends _RouteMapGeneric, Name extends keyof RouteMap > extends _RouteLocationBase { - name: Extract + name: Extract params: RouteMap[Name]['params'] /** @@ -53,7 +52,7 @@ export interface RouteLocationNormalizedTyped< RouteMap extends _RouteMapGeneric = _RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap > extends RouteLocationNormalized { - name: Extract + name: Extract // we don't override path because it could contain params and in practice it's just not useful params: RouteMap[Name]['params'] } @@ -74,7 +73,7 @@ export interface RouteLocationNormalizedLoadedTyped< RouteMap extends _RouteMapGeneric = _RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap > extends RouteLocationNormalizedLoaded { - name: Extract + name: Extract // we don't override path because it could contain params and in practice it's just not useful params: RouteMap[Name]['params'] } @@ -172,7 +171,7 @@ export type RouteLocationResolvedTypedList< * @see {@link RouteLocationNormalized} */ export type _RouteLocationNormalized< - Name extends _RouteRecordName = _RouteRecordName + Name extends RouteRecordName = RouteRecordName > = RouteLocationNormalizedTypedList[Name] /** @@ -180,7 +179,7 @@ export type _RouteLocationNormalized< * @see {@link RouteLocationNormalizedLoaded} */ export type _RouteLocationNormalizedLoaded< - Name extends _RouteRecordName = _RouteRecordName + Name extends RouteRecordName = RouteRecordName > = RouteLocationNormalizedLoadedTypedList[Name] /** @@ -188,7 +187,7 @@ export type _RouteLocationNormalizedLoaded< * @see {@link RouteLocationAsRelative} */ export type _RouteLocationAsRelativePath< - Name extends _RouteRecordName = _RouteRecordName + Name extends RouteRecordName = RouteRecordName > = RouteLocationAsRelativeTypedList[Name] /** diff --git a/packages/router/src/types/index.ts b/packages/router/src/types/index.ts index c9337dcb..2112208d 100644 --- a/packages/router/src/types/index.ts +++ b/packages/router/src/types/index.ts @@ -4,9 +4,10 @@ import { Ref, ComponentPublicInstance, Component, DefineComponent } from 'vue' import { RouteRecord, RouteRecordNormalized } from '../matcher/types' import { HistoryState } from '../history/common' import { NavigationFailure } from '../errors' -import { +import type { NavigationGuardWithThis, RouteLocation, + RouteRecordName, RouteRecordRedirectOption, } from '../typed-routes' import { _Awaitable } from './utils' @@ -214,11 +215,6 @@ export type RouteComponent = Component | DefineComponent */ export type RawRouteComponent = RouteComponent | Lazy -/** - * Possible values for a user-defined route record's name - */ -export type RouteRecordName = string | symbol - /** * @internal */