From fb9bb605d719dcc4b37f21bf0a5b8396dadcbdf3 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 4 Jan 2021 16:34:29 +0100 Subject: [PATCH] feat(types): add types for getRoutes addRoute --- types/index.d.ts | 1 + types/router.d.ts | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/types/index.d.ts b/types/index.d.ts index 504f2b56a..41bcea125 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -10,6 +10,7 @@ export { RouterOptions, RouteConfig, RouteRecord, + RouteRecordPublic, Location, Route, NavigationGuard, diff --git a/types/router.d.ts b/types/router.d.ts index ec48c7dca..03949ed4a 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -47,6 +47,11 @@ export declare class VueRouter { onReady(cb: Function, errorCb?: ErrorHandler): void onError(cb: ErrorHandler): void addRoutes(routes: RouteConfig[]): void + + addRoute(parent: string, route: RouteConfig): void + addRoute(route: RouteConfig): void + getRoutes(): RouteRecordPublic[] + resolve( to: RawLocation, current?: Route, @@ -158,6 +163,26 @@ export interface RouteRecord { | Dictionary } +export interface RouteRecordPublic { + path: string + components: Dictionary + instances: Dictionary + name?: string + redirect?: RedirectOption + meta: any + beforeEnter?: ( + route: Route, + redirect: (location: RawLocation) => void, + next: () => void + ) => any + props: + | boolean + | Object + | RoutePropsFunction + | Dictionary +} + + export interface Location { name?: string path?: string