-
-
Save Crisfole/99cecb549e08c2e28ff5f41b11d62d7e 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
// When importing an html file, assume it's a svelte component | |
declare module '*.html' { | |
type State = Record<string, any>; | |
type Changed = Record<string, boolean>; | |
type ChangeArgs = { | |
changed: Changed, | |
current: State, | |
previous: State | |
}; | |
interface Cancellable { | |
cancel: () => void | |
}; | |
export default class Component { | |
root: Component; | |
options: State; | |
constructor(init: { target: Element, data?: State }); | |
set(data: State) : void; | |
get(): State; | |
on(event: string, callback: (event: any) => void): Cancellable; | |
on(event: 'state', callback: (changeArgs: ChangeArgs) => void): Cancellable; | |
on(event: 'update', callback: (changeArgs: ChangeArgs) => void): Cancellable; | |
on(event: 'destroy', callback: () => void): Cancellable; | |
fire(event: string, data: any) : void; | |
destroy() : void; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment