throw new Error('not handled')
} else {
// use one single record
- // @ts-expect-error: One way or the other it failse
+ // @ts-expect-error: One way or the other it false
if (!resolved.matched) resolved.matched = record.map(normalizeRouteRecord)
// allow passing an expect.any(Array)
else if (Array.isArray(resolved.matched))
_ExtractFirstParamName,
_RemoveRegexpFromParam,
_RemoveUntilClosingPar,
+ JoinPath,
} from './types/paths'
export type { RouteNamedMap } from './types/named'
export type { Config, RouterTyped } from './typedRouter'
MatcherLocationRaw,
RouteParams,
RouteLocationNamedRaw,
+ RouteLocationPathRaw,
} from './types'
import { RouterHistory, HistoryState, NavigationType } from './history/common'
import {
>(
to: RouteNamedMapGeneric extends RouteMap
? RouteLocationRaw
- : RouteLocationNamedRaw<RouteMap, Name>
+ : RouteLocationNamedRaw<RouteMap, Name> | RouteLocationPathRaw | string
): Promise<NavigationFailure | void | undefined>
/**
>(
to: RouteNamedMapGeneric extends RouteMap
? RouteLocationRaw
- : RouteLocationNamedRaw<RouteMap, Name>
+ : RouteLocationNamedRaw<RouteMap, Name> | RouteLocationPathRaw | string
): Promise<NavigationFailure | void | undefined>
/**
resolve,
options,
- // @ts-expect-error: FIXME: can't type this one correctly without too much hussle
push,
- // @ts-expect-error: same
replace,
go,
back: () => go(-1),
-import { Router } from './router'
+import type { Router } from './router'
+/**
+ * Vue Router Configuration that allows to add global types for better type support.
+ *
+ * @example
+ *
+ * ```ts
+ * const router = createRouter({
+ * // ...
+ * routes: [
+ * // ...
+ * ] as const // IMPORTANT
+ * })
+ *
+ * declare module 'vue-router' {
+ * export interface Config {
+ * // allow global functions to get a typed router
+ * Router: typeof router
+ * }
+ * }
+ * ```
+ */
export interface Config {
// Router: unknown
}
-// export * from '../dist/vue-router'
-export * from '../src'
+export * from '../dist/vue-router'
+// export * from '../src'
export function describe(_name: string, _fn: () => void): void
export function expectType<T>(value: T): void
expectType,
RouteNamedMap,
RouterTyped,
- Router,
RouteLocationRaw,
+ JoinPath,
} from './index'
import { DefineComponent } from 'vue'
-import { JoinPath } from 'src/types/paths'
declare const component: DefineComponent
declare const components: { default: DefineComponent }
r2[method]({ name: 'UserDetails', params: { id: '2' } })
// accepts numbers
r2[method]({ name: 'UserDetails', params: { id: 2 } })
- // @ts-expect-error: fails an null
+ // @ts-expect-error: fails on null
r2[method]({ name: 'UserDetails', params: { id: null } })
// @ts-expect-error: and undefined
r2[method]({ name: 'UserDetails', params: { id: undefined } })
r2[method]({ name: Symbol() })
// any path is still valid
r2[method]('/path')
+ r2.push('/path')
+ r2.replace('/path')
// relative push can have any of the params
r2[method]({ params: { a: 2 } })
r2[method]({ params: {} })
r2[method]({ params: { opt: 'hey' } })
+ // FIXME: is it possible to support this version
+ // // @ts-expect-error: does not accept any params
+ // r2[method]({ name: 'nested', params: { eo: 'true' } })
}
r2.push({} as unknown as RouteLocationRaw)
// @ts-expect-error
}>(createMap(r2.options.routes))
-declare module '../src' {
- // declare module '../dist/vue-router' {
+// declare module '../src' {
+declare module '../dist/vue-router' {
export interface Config {
Router: typeof r2
}