[node]: Add missing stream properties (#38791)

* Add missing stream properties and tests

* Fix downstream issue in readable-stream

* add tests for readable-stream change
This commit is contained in:
Ben Lichtman
2019-10-01 17:31:59 -07:00
committed by GitHub
parent 47fc9ee659
commit 403ac51161
4 changed files with 18 additions and 0 deletions
+12
View File
@@ -1116,6 +1116,18 @@ import moduleModule = require('module');
moduleModule.createRequireFromPath('./test')('test');
}
/////////////////////////////////////////////////////////
/// stream tests : https://nodejs.org/api/stream.html ///
/////////////////////////////////////////////////////////
{
const writeStream = fs.createWriteStream('./index.d.ts');
const _wom = writeStream.writableObjectMode; // $ExpectType boolean
const readStream = fs.createReadStream('./index.d.ts');
const _rom = readStream.readableObjectMode; // $ExpectType boolean
}
////////////////////////////////////////////////////
/// Node.js ESNEXT Support
////////////////////////////////////////////////////
+3
View File
@@ -26,6 +26,7 @@ declare module "stream" {
readable: boolean;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly readableObjectMode: boolean;
destroyed: boolean;
constructor(opts?: ReadableOptions);
_read(size: number): void;
@@ -120,6 +121,7 @@ declare module "stream" {
readonly writableFinished: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly writableObjectMode: boolean;
destroyed: boolean;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
@@ -220,6 +222,7 @@ declare module "stream" {
readonly writableFinished: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly writableObjectMode: boolean;
constructor(opts?: DuplexOptions);
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
+1
View File
@@ -72,6 +72,7 @@ declare namespace _Readable {
readable: boolean;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly readableObjectMode: boolean;
_readableState: ReadableState;
_read(size?: number): void;
@@ -89,6 +89,8 @@ function test() {
assertType<boolean>(streamD.allowHalfOpen);
assertType<boolean>(streamD.readable);
assertType<boolean>(streamD.writable);
assertType<boolean>(streamD.readableObjectMode);
assertType<boolean>(streamD.writableObjectMode);
streamD.pipe(streamW);
rs.addListener("read", (...args: any[]) => console.log(args));