mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
[multistream] The last parameter in FactoryStream can take null (#22846)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
452e027d9b
commit
1b08e24cbe
9
types/multistream/index.d.ts
vendored
9
types/multistream/index.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user