Skip to content

Commit

Permalink
TypeScript - Fix return type of onDidChange, update dependencies (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender authored and sindresorhus committed Apr 11, 2019
1 parent c233707 commit 2bda368
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ declare class Conf<T = unknown> implements Iterable<[string, T]> {
onDidChange(
key: string,
callback: (oldValue: T | undefined, newValue: T | undefined) => void
): void;
): () => void;

[Symbol.iterator](): IterableIterator<[string, T]>;
}
Expand Down
5 changes: 4 additions & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ expectType<string | number | boolean>(conf.get('foo', 'bar'));
conf.delete('foo');
expectType<boolean>(conf.has('foo'));
conf.clear();
conf.onDidChange('foo', (oldValue, newValue) => {
const off = conf.onDidChange('foo', (oldValue, newValue) => {
expectType<string | number | boolean | undefined>(oldValue);
expectType<string | number | boolean | undefined>(newValue);
});

expectType<() => void>(off);
off();

conf.store = {
foo: 'bar',
unicorn: 'rainbow'
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
],
"dependencies": {
"ajv": "^6.10.0",
"dot-prop": "^4.2.0",
"env-paths": "^2.1.0",
"dot-prop": "^5.0.0",
"env-paths": "^2.2.0",
"json-schema-typed": "^7.0.0",
"make-dir": "^3.0.0",
"pkg-up": "^3.0.1",
"write-file-atomic": "^2.4.2"
},
"devDependencies": {
"@types/node": "^11.12.2",
"ava": "^1.4.0",
"clear-module": "^3.1.0",
"@types/node": "^11.13.4",
"ava": "^1.4.1",
"clear-module": "^3.2.0",
"del": "^4.1.0",
"tempy": "^0.2.1",
"tsd": "^0.7.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}

0 comments on commit 2bda368

Please sign in to comment.