Skip to content

Commit d1f35df

Browse files
authored
Merge pull request #1208 from sveltejs/gh-1207
Add TypeScript definitions for store (fixes #1207)
2 parents 5f51856 + 59d67f0 commit d1f35df

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"shared.js",
1414
"store.js",
1515
"store.umd.js",
16+
"store.d.ts",
1617
"svelte",
1718
"README.md"
1819
],

store.d.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
interface Options {
2+
immutable: boolean;
3+
}
4+
5+
interface Cancellable {
6+
cancel: () => void;
7+
}
8+
9+
type State = Record<string, any>;
10+
11+
export declare class Store {
12+
constructor(state: State, options?: Options);
13+
14+
public compute(key: string, dependencies: string[]): void;
15+
public fire(name: string, data?: any): void;
16+
public get(): State;
17+
public on(name: string, callback: (data: any) => void): Cancellable;
18+
public set(state: State);
19+
}

0 commit comments

Comments
 (0)