Last active
February 17, 2021 18:36
-
-
Save smmoosavi/4c56234c1c04d6c5e8b502ea5ab5b8f8 to your computer and use it in GitHub Desktop.
svelte-routing typings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'svelte-routing' { | |
import { SvelteComponent, SvelteComponentTyped } from 'svelte'; | |
interface LinkProps { | |
to: string; | |
replace?: boolean; | |
state?: { | |
[k in string | number]: unknown; | |
}; | |
getProps?: (linkParams: GetPropsParams) => Record<string, any>; | |
} | |
interface GetPropsParams { | |
location: RouteLocation; | |
href: string; | |
isPartiallyCurrent: boolean; | |
isCurrent: boolean; | |
} | |
class Link extends SvelteComponentTyped< | |
Omit<LinkProps & svelte.JSX.HTMLProps<HTMLAnchorElement> & svelte.JSX.SapperAnchorProps, 'href'> | |
> {} | |
export { Link }; | |
interface RouteProps { | |
path?: string; | |
component?: SvelteComponent; | |
[additionalProp: string]: unknown; | |
} | |
interface RouteSlots { | |
default: { | |
location: RouteLocation; | |
params: RouteParams; | |
}; | |
} | |
interface RouteLocation { | |
pathname: string; | |
search: string; | |
hash?: string; | |
state: { | |
[k in string | number]: unknown; | |
}; | |
} | |
interface RouteParams { | |
[param: string]: string; | |
} | |
class Route extends SvelteComponentTyped<RouteProps, Record<string, any>, RouteSlots> {} | |
export { Route, RouteLocation }; | |
interface RouterProps { | |
basepath?: string; | |
url?: string; | |
} | |
class Router extends SvelteComponentTyped<RouterProps> {} | |
export { Router }; | |
const link: (node: Element) => { destroy(): void }; | |
const links: (node: Element) => { destroy(): void }; | |
export { link, links }; | |
const navigate: ( | |
to: string, | |
{ | |
replace, | |
state, | |
}?: { | |
replace?: boolean; | |
state?: { | |
[k in string | number]: unknown; | |
}; | |
}, | |
) => void; | |
export { navigate }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment