Skip to content

Commit 034c71c

Browse files
committed
fix(types): add missing exported types
1 parent c88e6db commit 034c71c

File tree

6 files changed

+71
-12
lines changed

6 files changed

+71
-12
lines changed

src/RouterLink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface RouterLinkProps extends RouterLinkOptions {
5656
| 'false'
5757
}
5858

59-
type UseLinkOptions = VueUseOptions<RouterLinkOptions>
59+
export type UseLinkOptions = VueUseOptions<RouterLinkOptions>
6060

6161
// TODO: we could allow currentRoute as a prop to expose `isActive` and
6262
// `isExactActive` behavior should go through an RFC

src/history/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { removeTrailingSlash } from '../___location'
44
export type HistoryLocation = string
55
// ___pushState clones the state passed and do not accept everything
66
// it doesn't accept symbols, nor functions as values. It also ignores Symbols as keys
7+
/**
8+
* Allowed variables in HTML5 history state
9+
*/
710
type HistoryStateValue =
811
| string
912
| number
@@ -13,6 +16,9 @@ type HistoryStateValue =
1316
| HistoryState
1417
| HistoryStateArray
1518

19+
/**
20+
* Allowed HTML history.state
21+
*/
1622
export interface HistoryState {
1723
[x: number]: HistoryStateValue
1824
[x: string]: HistoryStateValue

src/index.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export { createWebHistory } from './history/html5'
22
export { createMemoryHistory } from './history/memory'
33
export { createWebHashHistory } from './history/hash'
4-
export { createRouterMatcher } from './matcher'
4+
export { createRouterMatcher, RouterMatcher } from './matcher'
55

66
export {
77
LocationQuery,
@@ -12,7 +12,7 @@ export {
1212
LocationQueryValueRaw,
1313
} from './query'
1414

15-
export { RouterHistory } from './history/common'
15+
export { RouterHistory, HistoryState } from './history/common'
1616

1717
export { RouteRecord, RouteRecordNormalized } from './matcher/types'
1818

@@ -30,27 +30,38 @@ export {
3030
} from './injectionSymbols'
3131

3232
export {
33-
RouteMeta,
33+
// route ___location
3434
_RouteLocationBase,
35-
_RouteRecordBase,
35+
LocationAsPath,
36+
LocationAsRelativeRaw,
37+
RouteQueryAndHash,
3638
RouteLocationRaw,
3739
RouteLocation,
3840
RouteLocationNormalized,
3941
RouteLocationNormalizedLoaded,
40-
START_LOCATION_NORMALIZED as START_LOCATION,
4142
RouteParams,
43+
RouteParamValue,
4244
RouteLocationMatched,
4345
RouteLocationOptions,
46+
RouteRecordRedirectOption,
47+
// route records
48+
_RouteRecordBase,
49+
RouteMeta,
50+
START_LOCATION_NORMALIZED as START_LOCATION,
51+
RouteComponent,
52+
// RawRouteComponent,
53+
RouteRecordName,
4454
RouteRecordRaw,
4555
NavigationGuard,
4656
NavigationGuardNext,
57+
NavigationGuardWithThis,
4758
NavigationHookAfter,
4859
} from './types'
60+
4961
export {
5062
createRouter,
5163
Router,
5264
RouterOptions,
53-
ErrorHandler,
5465
RouterScrollBehavior,
5566
} from './router'
5667

@@ -61,7 +72,12 @@ export {
6172
} from './errors'
6273

6374
export { onBeforeRouteLeave, onBeforeRouteUpdate } from './navigationGuards'
64-
export { RouterLink, useLink, RouterLinkProps } from './RouterLink'
75+
export {
76+
RouterLink,
77+
useLink,
78+
RouterLinkProps,
79+
UseLinkOptions,
80+
} from './RouterLink'
6581
export { RouterView, RouterViewProps } from './RouterView'
6682

6783
export * from './useApi'

src/matcher/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import {
1818
import { warn } from '../warning'
1919
import { assign, noop } from '../utils'
2020

21+
/**
22+
* Internal RouterMatcher
23+
*
24+
* @internal
25+
*/
2126
export interface RouterMatcher {
2227
addRoute: (record: RouteRecordRaw, parent?: RouteRecordMatcher) => () => void
2328
removeRoute: {

src/router.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import { addDevtools } from './devtools'
6767
* Internal type to define an ErrorHandler
6868
* @internal
6969
*/
70-
export type ErrorHandler = (error: any) => any
70+
export type _ErrorHandler = (error: any) => any
7171
// resolve, reject arguments of Promise constructor
7272
type OnReadyCallback = [() => void, (reason?: any) => void]
7373

@@ -304,7 +304,7 @@ export interface Router {
304304
*
305305
* @param handler - error handler to register
306306
*/
307-
onError(handler: ErrorHandler): () => void
307+
onError(handler: _ErrorHandler): () => void
308308
/**
309309
* Returns a Promise that resolves when the router has completed the initial
310310
* navigation, which means it has resolved all async enter hooks and async
@@ -978,7 +978,7 @@ export function createRouter(options: RouterOptions): Router {
978978
// Initialization and Errors
979979

980980
let readyHandlers = useCallbacks<OnReadyCallback>()
981-
let errorHandlers = useCallbacks<ErrorHandler>()
981+
let errorHandlers = useCallbacks<_ErrorHandler>()
982982
let ready: boolean
983983

984984
/**

src/types/index.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,42 @@ export type Immutable<T> = {
1313
readonly [P in keyof T]: Immutable<T[P]>
1414
}
1515

16+
/**
17+
* Type to transform a static object into one that allows passing Refs as
18+
* values.
19+
* @internal
20+
*/
1621
export type VueUseOptions<T> = {
1722
[k in keyof T]: Ref<T[k]> | T[k] | ComputedRef<T[k]>
1823
}
1924

2025
export type TODO = any
2126

27+
/**
28+
* @internal
29+
*/
2230
export type RouteParamValue = string
31+
/**
32+
* @internal
33+
*/
2334
export type RouteParamValueRaw = RouteParamValue | number
2435
export type RouteParams = Record<string, RouteParamValue | RouteParamValue[]>
2536
export type RouteParamsRaw = Record<
2637
string,
2738
RouteParamValueRaw | RouteParamValueRaw[]
2839
>
2940

30-
// TODO: document, mark as internal and export intermediate types for RouteLocationRaw
41+
/**
42+
* @internal
43+
*/
3144
export interface RouteQueryAndHash {
3245
query?: LocationQueryRaw
3346
hash?: string
3447
}
48+
49+
/**
50+
* @internal
51+
*/
3552
export interface LocationAsPath {
3653
path: string
3754
}
@@ -41,6 +58,9 @@ export interface LocationAsName {
4158
params?: RouteParams
4259
}
4360

61+
/**
62+
* @internal
63+
*/
4464
export interface LocationAsRelativeRaw {
4565
name?: RouteRecordName
4666
params?: RouteParamsRaw
@@ -157,9 +177,18 @@ export interface RouteLocationNormalized extends _RouteLocationBase {
157177
matched: RouteRecordNormalized[] // non-enumerable
158178
}
159179

180+
/**
181+
* Allowed Component in {@link RouteLocationMatched}
182+
*/
160183
export type RouteComponent = Component
184+
/**
185+
* Allowed Component definitions in route records provided by the user
186+
*/
161187
export type RawRouteComponent = RouteComponent | Lazy<RouteComponent>
162188

189+
/**
190+
* Possible values for a user-defined route record's name
191+
*/
163192
export type RouteRecordName = string | symbol
164193

165194
/**
@@ -221,6 +250,9 @@ export interface _RouteRecordBase extends PathParserOptions {
221250
*/
222251
export interface RouteMeta extends Record<string | number | symbol, any> {}
223252

253+
/**
254+
* @internal
255+
*/
224256
export type RouteRecordRedirectOption =
225257
| RouteLocationRaw
226258
| ((to: RouteLocation) => RouteLocationRaw)

0 commit comments

Comments
 (0)