From a09e943aad6944410c388789981f5a16561b691b Mon Sep 17 00:00:00 2001 From: nju33 Date: Sun, 12 Aug 2018 04:20:29 +0900 Subject: [PATCH] add type definitions for nanoevents --- types/nanoevents/index.d.ts | 14 ++++++++++++++ types/nanoevents/nanoevents-tests.ts | 8 ++++++++ types/nanoevents/tsconfig.json | 24 ++++++++++++++++++++++++ types/nanoevents/tslint.json | 1 + types/nanoevents/unbind-all.d.ts | 5 +++++ 5 files changed, 52 insertions(+) create mode 100644 types/nanoevents/index.d.ts create mode 100644 types/nanoevents/nanoevents-tests.ts create mode 100644 types/nanoevents/tsconfig.json create mode 100644 types/nanoevents/tslint.json create mode 100644 types/nanoevents/unbind-all.d.ts diff --git a/types/nanoevents/index.d.ts b/types/nanoevents/index.d.ts new file mode 100644 index 0000000000..0da2f0add3 --- /dev/null +++ b/types/nanoevents/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for nanoevents 1.0 +// Project: https://github.com/ai/nanoevents#readme +// Definitions by: nju33 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +declare function unbind(): void; + +declare class NanoEvents { + on(name: U, callBack: (arg: T[U]) => any): typeof unbind; + emit(name: U, value: T[U]): void; +} + +export = NanoEvents; diff --git a/types/nanoevents/nanoevents-tests.ts b/types/nanoevents/nanoevents-tests.ts new file mode 100644 index 0000000000..7e6eaa8cd8 --- /dev/null +++ b/types/nanoevents/nanoevents-tests.ts @@ -0,0 +1,8 @@ +import NanoEvents = require('nanoevents'); +import unbindAll = require('nanoevents/unbind-all'); + +const emitter = new NanoEvents<{foo: {foo: string}, bar: {bar: string}}>(); +const unbind = emitter.on('foo', action => action.foo); +emitter.emit('bar', {bar: 'test'}); +unbind(); +unbindAll(emitter); diff --git a/types/nanoevents/tsconfig.json b/types/nanoevents/tsconfig.json new file mode 100644 index 0000000000..d3291ed1d9 --- /dev/null +++ b/types/nanoevents/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "nanoevents-tests.ts", + "unbind-all.d.ts" + ] +} diff --git a/types/nanoevents/tslint.json b/types/nanoevents/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/nanoevents/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/nanoevents/unbind-all.d.ts b/types/nanoevents/unbind-all.d.ts new file mode 100644 index 0000000000..1f5662e493 --- /dev/null +++ b/types/nanoevents/unbind-all.d.ts @@ -0,0 +1,5 @@ +import NanoEmitter = require('.'); + +declare function unbindAll(emitter: NanoEmitter): void; + +export = unbindAll;