[multistream] The last parameter in FactoryStream can take null (#22846)

This commit is contained in:
Kenzie Togami
2018-01-12 10:01:15 -08:00
committed by Ryan Cavanaugh
parent 452e027d9b
commit 1b08e24cbe
2 changed files with 12 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
// Type definitions for multistream 2.1
// Project: https://github.com/feross/multistream
// Definitions by: mrmlnc <https://github.com/mrmlnc>
// Definitions by: mrmlnc <https://github.com/mrmlnc>, Kenzie Togami <https://github.com/kenzierocks>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -9,9 +9,14 @@ import { Stream } from 'stream';
declare function multistream(streams: multistream.Streams): NodeJS.ReadableStream;
interface FactoryStreamCallback {
(err: Error | null, stream: null): any;
(err: null, stream: NodeJS.ReadableStream): any;
}
declare namespace multistream {
type LazyStream = () => Stream;
type FactoryStream = (cb: (err: Error | null, stream: NodeJS.ReadableStream) => any) => void;
type FactoryStream = (cb: FactoryStreamCallback) => void;
type Streams = Array<LazyStream | NodeJS.ReadableStream> | FactoryStream;
function obj(streams: Streams): NodeJS.ReadableStream;

View File

@@ -26,6 +26,11 @@ const factory: multistream.FactoryStream = (cb) => {
if (1 === 1) return cb(null, fs.createReadStream('.filepath'));
cb(null, fs.createReadStream('.filepath'));
cb(null, null);
cb(new Error('some error'), null);
// $ExpectError
cb(new Error('some error'), fs.createReadStream('.filepath'));
};
// $ExpectType ReadableStream