Skip to content

Instantly share code, notes, and snippets.

@mrkishi
Created October 22, 2018 03:33
Show Gist options
  • Save mrkishi/eef15f253ca46688c19b85891debbab7 to your computer and use it in GitHub Desktop.
Save mrkishi/eef15f253ca46688c19b85891debbab7 to your computer and use it in GitHub Desktop.
Project-wide Svelte components type declaration for vscode
declare module '*.svelte' {
type Data = { [key]: any }
type Changed = { [key]: boolean }
type Listener = { cancel: () => void }
export default class Component {
root: Component
options: Data
constructor(init: { target: Element, data: Data })
set(data: Data)
get(): Data
on(event: string, callback: (event: any) => void): Listener
on(event: 'state', callback: ({ changed: Changed, current: Data, previous: Data }) => void): Listener
on(event: 'destroy', callback: () => void): Listener
fire(event: string, data: any)
destroy()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment