Created
November 18, 2018 22:20
-
-
Save mrkishi/bca74ae79df402ff47c51024103a265f to your computer and use it in GitHub Desktop.
Type definitions for Svelte components
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' { | |
type State = Record<string, any> | |
type Changed = Record<string, boolean> | |
interface Cancellable { | |
cancel: () => void | |
} | |
export default class Component { | |
root: Component | |
options: State | |
constructor(init: { target: Element, data?: State }) | |
set(data: State) | |
get(): State | |
on(event: string, callback: (event: any) => void): Cancellable | |
on(event: 'state', callback: ({ changed: Changed, current: State, previous: State }) => void): Cancellable | |
on(event: 'destroy', callback: () => void): Cancellable | |
fire(event: string, data: any) | |
destroy() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment