From: Eduardo San Martin Morote Date: Tue, 16 Apr 2019 16:52:57 +0000 (+0200) Subject: feat(types): stricter query in normalized route X-Git-Tag: v4.0.0-alpha.0~434 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7d909617857b3e4c32850a8ef3f9a8ac5d50beea;p=thirdparty%2Fvuejs%2Frouter.git feat(types): stricter query in normalized route --- diff --git a/src/types/index.ts b/src/types/index.ts index f1e4fb5e..7aa0ef4e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,3 +1,5 @@ +import { HistoryQuery } from '../history/base' + type TODO = any // TODO: support numbers for easier writing but cast them @@ -28,16 +30,12 @@ export type RouteLocation = | RouteQueryAndHash & LocationAsName | RouteQueryAndHash & LocationAsRelative -// the matcher doesn't care about query and hash -export type MatcherLocation = - | LocationAsPath - | LocationAsName - | LocationAsRelative - // exposed to the user in a very consistant way export interface RouteLocationNormalized extends Required { fullPath: string + query: HistoryQuery // the normalized version cannot have numbers + // TODO: do the same for params name: string | void } @@ -68,6 +66,7 @@ export const START_RECORD: RouteRecord = { component: { render: h => h() }, } +// TODO: this should probably be generate by ensureLocation export const START_LOCATION_NORMALIZED: RouteLocationNormalized = { path: '/', name: undefined, @@ -78,8 +77,12 @@ export const START_LOCATION_NORMALIZED: RouteLocationNormalized = { } // Matcher types -// TODO: can probably have types with no record, path and others -// should be an & type +// the matcher doesn't care about query and hash +export type MatcherLocation = + | LocationAsPath + | LocationAsName + | LocationAsRelative + export interface MatcherLocationNormalized { name: RouteLocationNormalized['name'] path: string