Skip to content

Instantly share code, notes, and snippets.

@mrkishi
Created November 18, 2018 22:20
Show Gist options
  • Save mrkishi/bca74ae79df402ff47c51024103a265f to your computer and use it in GitHub Desktop.
Save mrkishi/bca74ae79df402ff47c51024103a265f to your computer and use it in GitHub Desktop.
Type definitions for Svelte components
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