From 4159c1d0606ad7f6e692ee41ab7213f7bc2a1218 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 10 Dec 2018 02:13:15 +0100 Subject: [PATCH] Add types for on-change --- types/on-change/index.d.ts | 9 +++++++++ types/on-change/on-change-tests.ts | 17 +++++++++++++++++ types/on-change/tsconfig.json | 23 +++++++++++++++++++++++ types/on-change/tslint.json | 1 + 4 files changed, 50 insertions(+) create mode 100644 types/on-change/index.d.ts create mode 100644 types/on-change/on-change-tests.ts create mode 100644 types/on-change/tsconfig.json create mode 100644 types/on-change/tslint.json diff --git a/types/on-change/index.d.ts b/types/on-change/index.d.ts new file mode 100644 index 0000000000..44fff26e60 --- /dev/null +++ b/types/on-change/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for on-change 0.1 +// Project: https://github.com/sindresorhus/on-change#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = onChange; + +declare function onChange(object: T, onChange: () => void): T; diff --git a/types/on-change/on-change-tests.ts b/types/on-change/on-change-tests.ts new file mode 100644 index 0000000000..003d89aab7 --- /dev/null +++ b/types/on-change/on-change-tests.ts @@ -0,0 +1,17 @@ +import onChange = require('on-change'); + +const object = { + foo: false, + a: { + b: [ + { + c: false, + }, + ], + }, +}; + +const watchedObject = onChange(object, () => {}); + +watchedObject.foo = true; +watchedObject.a.b[0].c = true; diff --git a/types/on-change/tsconfig.json b/types/on-change/tsconfig.json new file mode 100644 index 0000000000..433629ab82 --- /dev/null +++ b/types/on-change/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "on-change-tests.ts" + ] +} diff --git a/types/on-change/tslint.json b/types/on-change/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/on-change/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }