feat(types/cloneable-readable): add new types (#25570)

This commit is contained in:
Nikita Volodin
2018-05-07 12:03:26 -04:00
committed by Andy
parent 552460da3a
commit aca0178bcc
4 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
import { PassThrough } from 'stream';
import cloneable = require('cloneable-readable');
const ps = new PassThrough(); // $ExpectType PassThrough
const cl = cloneable(ps); // $ExpectType Cloneable<PassThrough>
process.stdin.pipe(cl.clone()).pipe(process.stderr);
process.stdin.pipe(cl).pipe(process.stdout);
cloneable.isCloneable(ps); // $ExpectType boolean
cloneable.isCloneable(cl); // $ExpectType boolean

17
types/cloneable-readable/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for cloneable-readable 1.1
// Project: https://github.com/mcollina/cloneable-readable#readme
// Definitions by: Nikita Volodin <https://github.com/qlonik>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node"/>
import { Readable } from 'stream';
type Cloneable<T> = T & { clone(): Cloneable<T> };
interface CloneableFn {
<T extends Readable>(x: T): Cloneable<T>;
isCloneable(x: Readable): boolean;
}
declare const cloneable: CloneableFn;
export = cloneable;

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",
"cloneable-readable-tests.ts"
]
}

View File

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