forked from sindresorhus/electron-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test-d.ts
55 lines (44 loc) · 943 Bytes
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {expectType} from 'tsd';
import Store = require('.');
new Store({defaults: {}});
new Store({name: 'myConfiguration'});
const store = new Store();
store.set('foo', 'bar');
store.set({
foo: 'bar',
foo2: 'bar2'
});
store.delete('foo');
store.get('foo');
store.get('foo', 42);
store.has('foo');
store.clear();
store.openInEditor();
store.size;
store.store;
store.store = {
foo: 'bar'
};
store.path;
const typedStore = new Store<number | boolean>({
defaults: {
enabled: true,
interval: 30000
}
});
expectType<number | boolean>(typedStore.get('interval'));
const enabled = false;
typedStore.set('enabled', enabled);
typedStore.set({
enabled: true,
interval: 10000
});
const offDidChange = typedStore.onDidChange(
'enabled',
(oldValue, newValue) => {
expectType<number | boolean | undefined>(oldValue);
expectType<number | boolean | undefined>(newValue);
}
);
expectType<() => void>(offDidChange);
offDidChange();