Skip to content

Commit

Permalink
Update type comment
Browse files Browse the repository at this point in the history
  • Loading branch information
moheng233 authored and ItalyPaleAle committed Oct 22, 2020
1 parent 9879d8f commit b462265
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface RouteDetail {
route: string | RegExp;
location: string;
querystring: string;
userData?: {};
component?: {};
name?: string;
}
13 changes: 13 additions & 0 deletions active.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface ActiveOptions {
path: string | RegExp;
className: string;
}

/**
* Svelte Action for automatically adding the "active" class to elements (links, or any other DOM element) when the current location matches a certain path.
*
* @param node - The target node (automatically set by Svelte)
* @param opts - Can be an object of type ActiveOptions, or a string (or regular expressions) representing ActiveOptions.path.
* @returns Destroy function
*/
export declare function active(node: HTMLElement,opt?: ActiveOptions | string | RegExp): {destroy: () => void};
34 changes: 34 additions & 0 deletions warp.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { SvelteComponent } from 'svelte'
import { RouteDetail } from './Router'

interface WrappedComponent {
component: SvelteComponent;
conditions?: RoutePrecondition[];
props?: {};
userData?: {};
_sveltesparouter: boolean;
}

type RoutePrecondition = (detail: any) => boolean

interface WarpOptions {
component?: SvelteComponent;
asyncComponent?: () => Promise<SvelteComponent>;
loadingComponent?: SvelteComponent;
loadingParams?: SvelteComponent;
userData?: {};
props?: {};
conditions?: ((detail: RouteDetail) => boolean)[] | ((detail: RouteDetail) => boolean);
}
/**
* Wraps a component to enable multiple capabilities:
* 1. Using dynamically-imported component, with (e.g. `{asyncComponent: () => import('Foo.svelte')}`), which also allows bundlers to do code-splitting.
* 2. Adding route pre-conditions (e.g. `{conditions: [...]}`)
* 3. Adding static props that are passed to the component
* 4. Adding custom userData, which is passed to route events (e.g. route loaded events) or to route pre-conditions (e.g. `{userData: {foo: 'bar}}`)
*
* @param args - Arguments object
* @returns Wrapped component
*/
export declare function warp(args:WarpOptions):WrappedComponent;
export default warp;

0 comments on commit b462265

Please sign in to comment.