From: Eduardo San Martin Morote Date: Sun, 22 Mar 2020 18:19:37 +0000 (+0100) Subject: docs: improve tsdoc X-Git-Tag: v4.0.0-alpha.4~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58f48bb808e410825583b5956e091e1a22cd12af;p=thirdparty%2Fvuejs%2Frouter.git docs: improve tsdoc --- diff --git a/src/history/common.ts b/src/history/common.ts index 41efecb1..a59b9dd7 100644 --- a/src/history/common.ts +++ b/src/history/common.ts @@ -90,7 +90,7 @@ export interface RouterHistory { /** * Transforms an URI into a normalized history location * @param parseQuery - * @param location URI to normalize + * @param location - URI to normalize * @returns a normalized history location */ export function parseURL( @@ -148,8 +148,8 @@ export function stringifyURL( /** * Strips off the base from the beginning of a location.pathname - * @param pathname location.pathname - * @param base base to strip off + * @param pathname - location.pathname + * @param base - base to strip off */ export function stripBase(pathname: string, base: string): string { if (!base || pathname.indexOf(base) !== 0) return pathname diff --git a/src/index.ts b/src/index.ts index 567d35d5..8dbeb57e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,8 @@ import createWebHashHistory from './history/hash' import { inject } from 'vue' import { routerKey, routeLocationKey } from './utils/injectionSymbols' +export { RouterHistory } from './history/common' + export { RouteLocationNormalized, RouteLocationOptions, diff --git a/src/matcher/index.ts b/src/matcher/index.ts index 9a1888ff..1f4e9d65 100644 --- a/src/matcher/index.ts +++ b/src/matcher/index.ts @@ -173,8 +173,8 @@ export function createRouterMatcher( /** * Resolves a location. Gives access to the route record that corresponds to the actual path as well as filling the corresponding params objects - * @param location MatcherLocation to resolve to a url - * @param currentLocation MatcherLocationNormalized of the current location + * @param location - MatcherLocation to resolve to a url + * @param currentLocation - MatcherLocationNormalized of the current location */ function resolve( location: Readonly, diff --git a/src/matcher/path-parser-ranker.ts b/src/matcher/path-parser-ranker.ts index 3ff0e324..bd65ed11 100644 --- a/src/matcher/path-parser-ranker.ts +++ b/src/matcher/path-parser-ranker.ts @@ -28,14 +28,14 @@ export interface PathParser { * Parses a url and returns the matched params or nul if it doesn't match. An * optional param that isn't preset will be an empty string. A repeatable * param will be an array if there is at least one value. - * @param path url to parse + * @param path - url to parse * @returns a Params object, empty if there are no params. `null` if there is * no match */ parse(path: string): PathParams | null /** * Creates a string version of the url - * @param params object of params + * @param params - object of params * @returns a url */ stringify(params: PathParams): string @@ -93,8 +93,8 @@ const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g /** * Creates a path parser from an array of Segments (a segment is an array of Tokens) * - * @param segments array of segments returned by tokenizePath - * @param extraOptions optional options for the regexp + * @param segments - array of segments returned by tokenizePath + * @param extraOptions - optional options for the regexp * @returns a PathParser */ export function tokensToParser( @@ -253,8 +253,8 @@ export function tokensToParser( /** * Compares an array of numbers as used in PathParser.score and returns a * number. This function can be used to `sort` an array - * @param a first array of numbers - * @param b second array of numbers + * @param a - first array of numbers + * @param b - second array of numbers * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b * should be sorted first */ @@ -285,8 +285,8 @@ function compareScoreArray(a: number[], b: number[]): number { /** * Compare function that can be used with `sort` to sort an array of PathParser - * @param a first PathParser - * @param b second PathParser + * @param a - first PathParser + * @param b - second PathParser * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b */ export function comparePathParserScore(a: PathParser, b: PathParser): number { diff --git a/src/router.ts b/src/router.ts index bdb819b6..119285e0 100644 --- a/src/router.ts +++ b/src/router.ts @@ -451,8 +451,8 @@ export function createRouter({ /** * Trigger errorHandlers added via onError and throws the error as well - * @param error error to throw - * @param shouldThrow defaults to true. Pass false to not throw the error + * @param error - error to throw + * @param shouldThrow - defaults to true. Pass false to not throw the error */ function triggerError(error: any, shouldThrow: boolean = true): void { markAsReady(error) @@ -479,7 +479,7 @@ export function createRouter({ /** * Mark the router as ready, resolving the promised returned by isReady(). Can * only be called once, otherwise does nothing. - * @param err optional error + * @param err - optional error */ function markAsReady(err?: any): void { if (ready) return diff --git a/src/types/index.ts b/src/types/index.ts index 93f502c0..12c3f595 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -108,18 +108,18 @@ export interface RouteComponentInterface { /** * Guard called when the router is navigating away from the current route * that is rendering this component. - * @param to RouteLocation we are navigating to - * @param from RouteLocation we are navigating from - * @param next function to validate, cancel or modify (by redirectering) the navigation + * @param to - RouteLocation we are navigating to + * @param from - RouteLocation we are navigating from + * @param next - function to validate, cancel or modify (by redirectering) the navigation */ beforeRouteLeave?: NavigationGuard /** * Guard called whenever the route that renders this component has changed but * it is reused for the new route. This allows you to guard for changes in params, * the query or the hash. - * @param to RouteLocation we are navigating to - * @param from RouteLocation we are navigating from - * @param next function to validate, cancel or modify (by redirectering) the navigation + * @param to - RouteLocation we are navigating to + * @param from - RouteLocation we are navigating from + * @param next - function to validate, cancel or modify (by redirectering) the navigation */ beforeRouteUpdate?: NavigationGuard } diff --git a/src/utils/query.ts b/src/utils/query.ts index 7ef1bc3f..4d1ff4d6 100644 --- a/src/utils/query.ts +++ b/src/utils/query.ts @@ -14,7 +14,7 @@ export type LocationQueryRaw = Record< /** * Transform a queryString into a query object. Accept both, a version with the leading `?` and without * Should work as URLSearchParams - * @param search + * @param search - search string to parse * @returns a query object */ export function parseQuery(search: string): LocationQuery { @@ -48,7 +48,7 @@ export function parseQuery(search: string): LocationQuery { /** * Stringify an object query. Works like URLSearchParams. Doesn't prepend a `?` - * @param query + * @param query - query object to stringify */ export function stringifyQuery(query: LocationQueryRaw): string { let search = '' @@ -80,7 +80,7 @@ export function stringifyQuery(query: LocationQueryRaw): string { * Transforms a RawQuery intoe a NormalizedQuery by casting numbers into * strings, removing keys with an undefined value and replacing undefined with * null in arrays - * @param query + * @param query - query object to normalize */ export function normalizeQuery( query: LocationQueryRaw | undefined