From ba2658ec80863285dfae7044299f05ca757e64bc Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Tue, 1 Dec 2020 08:58:39 -0800 Subject: [PATCH] This should fix types --- Router.d.ts | 80 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/Router.d.ts b/Router.d.ts index 056aaee..4710c5c 100644 --- a/Router.d.ts +++ b/Router.d.ts @@ -161,40 +161,50 @@ export type RouteLoadingEvent = RouterEvent export type RouteLoadedEvent = RouterEvent /** - * Router component + * Interface for the props for the Router component */ -export default class Router extends SvelteComponent { - // Props - $$prop_def: { - /** - * Dictionary of all routes, in the format `'/path': component`. - * - * For example: - * ````js - * import HomeRoute from './routes/HomeRoute.svelte' - * import BooksRoute from './routes/BooksRoute.svelte' - * import NotFoundRoute from './routes/NotFoundRoute.svelte' - * routes = { - * '/': HomeRoute, - * '/books': BooksRoute, - * '*': NotFoundRoute - * } - * ```` - */ - routes: RouteDefinition, - /** - * Optional prefix for the routes in this router. This is useful for example in the case of nested routers. - */ - prefix?: string | RegExp, - /** - * If set to true, the router will restore scroll positions on back navigation - * and scroll to top on forward navigation. - */ - restoreScrollState?: boolean - } - - $on(event: 'routeEvent', callback: (event: CustomEvent) => void): () => void - $on(event: 'conditionsFailed', callback: (event: ConditionsFailedEvent) => void): () => void - $on(event: 'routeLoading', callback: (event: RouteLoadingEvent) => void): () => void - $on(event: 'routeLoaded', callback: (event: RouteLoadedEvent) => void): () => void +interface RouterPropsDef { + /** + * Dictionary of all routes, in the format `'/path': component`. + * + * For example: + * ````js + * import HomeRoute from './routes/HomeRoute.svelte' + * import BooksRoute from './routes/BooksRoute.svelte' + * import NotFoundRoute from './routes/NotFoundRoute.svelte' + * routes = { + * '/': HomeRoute, + * '/books': BooksRoute, + * '*': NotFoundRoute + * } + * ```` + */ + routes: RouteDefinition + /** + * Optional prefix for the routes in this router. This is useful for example in the case of nested routers. + */ + prefix?: string | RegExp + /** + * If set to true, the router will restore scroll positions on back navigation + * and scroll to top on forward navigation. + */ + restoreScrollState?: boolean } + +/** + * Interface for the events for the Router component + */ +interface RouterEventsDef { + routeEvent: CustomEvent, + conditionsFailed: ConditionsFailedEvent + routeLoading: RouteLoadingEvent + routeLoaded: RouteLoadedEvent +} + +/** + * Router component + */ +export default class Router extends SvelteComponent< + RouterPropsDef, + RouterEventsDef +> {}