diff --git a/types/zen-push/index.d.ts b/types/zen-push/index.d.ts new file mode 100644 index 0000000000..f5d7e5046d --- /dev/null +++ b/types/zen-push/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for zen-push 0.1 +// Project: https://github.com/zenparsing/zen-push +// Definitions by: daprahamian +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as Observable from 'zen-observable'; + +declare class PushStream { + readonly observable: Observable; + readonly observed: number; + next(x: T): void; + error(e: Error): void; + complete(x?: any): void; +} + +export default PushStream; diff --git a/types/zen-push/tsconfig.json b/types/zen-push/tsconfig.json new file mode 100644 index 0000000000..d3e8efb833 --- /dev/null +++ b/types/zen-push/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", + "zen-push-tests.ts" + ] +} diff --git a/types/zen-push/tslint.json b/types/zen-push/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/zen-push/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/zen-push/zen-push-tests.ts b/types/zen-push/zen-push-tests.ts new file mode 100644 index 0000000000..79abc517e8 --- /dev/null +++ b/types/zen-push/zen-push-tests.ts @@ -0,0 +1,21 @@ +import PushStream from 'zen-push'; +import * as Observable from 'zen-observable'; + +function assert(val: boolean) { + if (!val) { + throw new Error('Assertion Failure'); + } +} + +const stream1 = new PushStream(); + +assert(stream1.observable instanceof Observable); +assert(typeof stream1.observed === 'number'); + +stream1.next(15); + +stream1.next(23); + +stream1.error(new Error('test 123')); + +stream1.complete();