import { assign } from './utils'
/**
- * Flags so we can combine them when checking for multiple errors
+ * Flags so we can combine them when checking for multiple errors. This is the internal version of
+ * {@link NavigationFailureType}.
+ *
+ * @internal
*/
export const enum ErrorTypes {
// they must be literals to be used as values so we can't write
to: RouteLocationNormalized
}
+/**
+ * Internal error used to detect a redirection.
+ *
+ * @internal
+ */
export interface NavigationRedirectError
extends Omit<NavigationFailure, 'to' | 'type'> {
type: ErrorTypes.NAVIGATION_GUARD_REDIRECT
import { removeTrailingSlash } from '../location'
export type HistoryLocation = string
-// pushState clones the state passed and do not accept everything
-// it doesn't accept symbols, nor functions as values. It also ignores Symbols as keys
/**
- * Allowed variables in HTML5 history state
+ * Allowed variables in HTML5 history state. Note that pushState clones the state
+ * passed and does not accept everything: e.g it doesn't accept symbols, nor
+ * functions as values. It also ignores Symbols as keys.
+ *
+ * @internal
*/
-type HistoryStateValue =
+export type HistoryStateValue =
| string
| number
| boolean
[x: number]: HistoryStateValue
[x: string]: HistoryStateValue
}
-interface HistoryStateArray extends Array<HistoryStateValue> {}
+
+/**
+ * Allowed arrays for history.state.
+ *
+ * @internal
+ */
+export interface HistoryStateArray extends Array<HistoryStateValue> {}
export enum NavigationType {
pop = 'pop',
import { warn } from '../warning'
/**
- * Creates a hash history. Useful for web applications with no host (e.g.
- * `file://`) or when configuring a server to handle any URL is not possible.
+ * Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
+ * handle any URL is not possible.
*
- * @param base - optional base to provide. Defaults to `location.pathname +
- * location.search` If there is a `<base>` tag in the `head`, its value will be
- * ignored in favor of this parameter **but note it affects all the
- * history.pushState() calls**, meaning that if you use a `<base>` tag, it's
- * `href` value **has to match this parameter** (ignoring anything after the
- * `#`).
+ * @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
+ * in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
+ * calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
+ * after the `#`).
*
* @example
* ```js
RouteParamsRaw,
RouteParamValue,
RouteParamValueRaw,
+ RouteLocationNamedRaw,
+ RouteLocationPathRaw,
+ RouteLocationString,
RouteLocationMatched,
RouteLocationOptions,
RouteRecordRedirectOption,
_RemoveRegexpFromParam,
_RemoveUntilClosingPar,
_JoinPath as JoinPath,
+ _ParamDelimiter,
+ _ParamModifier,
} from './types/paths'
-export type { RouteNamedMap } from './types/named'
+export type {
+ RouteNamedMap,
+ RouteStaticPathMap,
+ RouteNamedInfo,
+ _RouteRecordNamedBaseInfo,
+} from './types/named'
export type { Config, RouterTyped } from './typedRouter'
export { createRouter } from './router'
export type { Router, RouterOptions, RouterScrollBehavior } from './router'
export { NavigationFailureType, isNavigationFailure } from './errors'
-export type { NavigationFailure } from './errors'
+export type {
+ NavigationFailure,
+ ErrorTypes,
+ NavigationRedirectError,
+} from './errors'
export {
onBeforeRouteLeave,
// normalize component/components into components and make every property always present
/**
- * Normalized version of a {@link RouteRecord route record}
+ * Normalized version of a {@link RouteRecord | route record}.
*/
export interface RouteRecordNormalized {
/**
* {@link RouterOptions.stringifyQuery}.
*
* @example
- * Let's say you want to use the package {@link https://github.com/ljharb/qs | qs}
+ * Let's say you want to use the [qs package](https://github.com/ljharb/qs)
* to parse queries, you can provide both `parseQuery` and `stringifyQuery`:
* ```js
* import qs from 'qs'
listening: boolean
/**
- * Add a new {@link RouteRecordRaw route record} as the child of an existing route.
+ * Add a new {@link RouteRecordRaw | route record} as the child of an existing route.
*
* @param parentName - Parent Route Record where `route` should be appended at
* @param route - Route Record to add
*/
addRoute(parentName: RouteRecordName, route: RouteRecordRaw): () => void
/**
- * Add a new {@link RouteRecordRaw route record} to the router.
+ * Add a new {@link RouteRecordRaw | route record} to the router.
*
* @param route - Route Record to add
*/
*/
hasRoute(name: RouteRecordName): boolean
/**
- * Get a full list of all the {@link RouteRecord route records}.
+ * Get a full list of all the {@link RouteRecord | route records}.
*/
getRoutes(): RouteRecord[]
/**
- * Returns the {@link RouteLocation normalized version} of a
- * {@link RouteLocationRaw route location}. Also includes an `href` property
+ * Returns the {@link RouteLocation | normalized version} of a
+ * {@link RouteLocationRaw | route location}. Also includes an `href` property
* that includes any existing `base`. By default the `currentLocation` used is
* `route.currentRoute` and should only be overridden in advanced use cases.
*
/**
* Relevant information about a named route record to deduce its params.
+ *
* @internal
*/
export interface RouteNamedInfo<
*
* @internal
*/
-type _ParamDelimiter =
+export type _ParamDelimiter =
| '-'
| '/'
| '%'
* Takes the custom regex (and everything after) of a param and strips it off.
*
* @example
- * - `\\d+(?:inner-group\\)-end)/:rest-of-url` -> `/:rest-of-url`
+ * - `\\d+(?:inner-group\\)-end)/:rest-of-url` becomes `/:rest-of-url`
*
* @internal
*/
| readonly never[]
/**
- * Recursively builds a path from a {param} based path
+ * Recursively builds a path from a param based path with curly braces (e.g. `\{id\}`).
*
* @internal
*/