feat(zen-push): adding types for zen-push (#20476)

This commit is contained in:
daprahamian 2017-10-11 18:49:13 -04:00 committed by Wesley Wigham
parent 28e995bbff
commit 5b6f5ef807
4 changed files with 61 additions and 0 deletions

16
types/zen-push/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
// Type definitions for zen-push 0.1
// Project: https://github.com/zenparsing/zen-push
// Definitions by: daprahamian <https://github.com/daprahamian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as Observable from 'zen-observable';
declare class PushStream<T> {
readonly observable: Observable<T>;
readonly observed: number;
next(x: T): void;
error(e: Error): void;
complete(x?: any): void;
}
export default PushStream;

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -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<number>();
assert(stream1.observable instanceof Observable);
assert(typeof stream1.observed === 'number');
stream1.next(15);
stream1.next(23);
stream1.error(new Error('test 123'));
stream1.complete();