]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
chore: types housekeeping
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 10 Jun 2022 14:57:49 +0000 (16:57 +0200)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 30 Jun 2022 07:59:00 +0000 (09:59 +0200)
packages/router/src/errors.ts
packages/router/src/history/common.ts
packages/router/src/history/hash.ts
packages/router/src/index.ts
packages/router/src/matcher/types.ts
packages/router/src/router.ts
packages/router/src/types/named.ts
packages/router/src/types/paths.ts

index c466f9a3b9747a9801af32f5288d5ebaa3a0d096..afae094a50f8a8b6896559411566f0d327e7d541 100644 (file)
@@ -7,7 +7,10 @@ import {
 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
@@ -70,6 +73,11 @@ export interface NavigationFailure extends Error {
   to: RouteLocationNormalized
 }
 
+/**
+ * Internal error used to detect a redirection.
+ *
+ * @internal
+ */
 export interface NavigationRedirectError
   extends Omit<NavigationFailure, 'to' | 'type'> {
   type: ErrorTypes.NAVIGATION_GUARD_REDIRECT
index b203f17b7f614f7a1499472b48f5a2cb3e0bcd54..3476777a8dd8cfcfb2f22d43b28af3d55c0b6340 100644 (file)
@@ -2,12 +2,14 @@ import { isBrowser } from '../utils'
 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
@@ -23,7 +25,13 @@ export interface HistoryState {
   [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',
index 522b6c9e5cbb4903f85f61459d09b0e9515c69e0..f1cedefd5d96c00586f6e3fd9986e44ba15123f2 100644 (file)
@@ -3,15 +3,13 @@ import { createWebHistory } from './html5'
 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
index 9e978d7fd498baacd02528d7d9659552336e6d84..8624db20aebb407f753393098f3aad476879887f 100644 (file)
@@ -44,6 +44,9 @@ export type {
   RouteParamsRaw,
   RouteParamValue,
   RouteParamValueRaw,
+  RouteLocationNamedRaw,
+  RouteLocationPathRaw,
+  RouteLocationString,
   RouteLocationMatched,
   RouteLocationOptions,
   RouteRecordRedirectOption,
@@ -65,15 +68,26 @@ export type {
   _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,
index cf8e0d2e02a588be683b27e56a79d0ecdf02da1a..f48c752215f962f834c2a2805a22f14d1d7cffa4 100644 (file)
@@ -10,7 +10,7 @@ import { ComponentPublicInstance } from 'vue'
 
 // 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 {
   /**
index 72d4534f62cdf79947c7b431ce61037a2671a922..d60028988151dd6db8190b45b528143e8d9d8d97 100644 (file)
@@ -149,7 +149,7 @@ export interface RouterOptions extends PathParserOptions {
    * {@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'
@@ -207,14 +207,14 @@ export interface Router<Options extends RouterOptions = RouterOptions> {
   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
    */
@@ -232,13 +232,13 @@ export interface Router<Options extends RouterOptions = RouterOptions> {
    */
   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.
    *
index d343262f25098a9ddad08df4437f237f235fb5d0..a662969ffff74ea05982be97559687cc8451c6f3 100644 (file)
@@ -148,6 +148,7 @@ export type RouteStaticPathMapGeneric = Record<
 
 /**
  * Relevant information about a named route record to deduce its params.
+ *
  * @internal
  */
 export interface RouteNamedInfo<
index e1888fa2d78e96b40dcc363cf9027aab2bb3e855..e2318e346ffab5853f6ce819d9b2b8706481a50d 100644 (file)
@@ -41,7 +41,7 @@ export type _ParamModifier = '+' | '?' | '*'
  *
  * @internal
  */
-type _ParamDelimiter =
+export type _ParamDelimiter =
   | '-'
   | '/'
   | '%'
@@ -153,7 +153,7 @@ export type _ParamToObject<
  * 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
  */
@@ -260,7 +260,7 @@ type _PossibleModifierValue =
   | 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
  */