diff --git a/types/node/globals.d.ts b/types/node/globals.d.ts index 5de9e98fae..9df7727759 100644 --- a/types/node/globals.d.ts +++ b/types/node/globals.d.ts @@ -737,31 +737,6 @@ declare namespace NodeJS { [key: string]: string | undefined; } - interface WriteStream extends Socket { - readonly writableFinished: boolean; - readonly writableHighWaterMark: number; - readonly writableLength: number; - columns?: number; - rows?: number; - _write(chunk: any, encoding: string, callback: (err?: null | Error) => void): void; - _destroy(err: Error | null, callback: (err?: null | Error) => void): void; - _final(callback: (err?: null | Error) => void): void; - setDefaultEncoding(encoding: string): this; - cork(): void; - uncork(): void; - destroy(error?: Error): void; - } - interface ReadStream extends Socket { - readonly readableHighWaterMark: number; - readonly readableLength: number; - isRaw?: boolean; - setRawMode?(mode: boolean): void; - _read(size: number): void; - _destroy(err: Error | null, callback: (err?: null | Error) => void): void; - push(chunk: any, encoding?: string): boolean; - destroy(error?: Error): void; - } - interface HRTime { (time?: [number, number]): [number, number]; } diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index e98cd062d6..e8a65c0def 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1119,6 +1119,8 @@ import moduleModule = require('module'); ///////////////////////////////////////////////////////// /// stream tests : https://nodejs.org/api/stream.html /// ///////////////////////////////////////////////////////// +import stream = require('stream'); +import tty = require('tty'); { const writeStream = fs.createWriteStream('./index.d.ts'); @@ -1126,6 +1128,11 @@ import moduleModule = require('module'); const readStream = fs.createReadStream('./index.d.ts'); const _rom = readStream.readableObjectMode; // $ExpectType boolean + + const x: stream.Readable = process.stdin; + const stdin: tty.ReadStream = process.stdin; + const stdout: tty.WriteStream = process.stdout; + const stderr: tty.WriteStream = process.stderr; } //////////////////////////////////////////////////// diff --git a/types/node/process.d.ts b/types/node/process.d.ts index ccd5c9c198..d007d4e004 100644 --- a/types/node/process.d.ts +++ b/types/node/process.d.ts @@ -1,3 +1,15 @@ declare module "process" { + import * as tty from "tty"; + + global { + namespace NodeJS { + // this namespace merge is here because these are specifically used + // as the type for process.stdin, process.stdout, and process.stderr. + // they can't live in tty.d.ts because we need to disambiguate the imported name. + interface ReadStream extends tty.ReadStream {} + interface WriteStream extends tty.WriteStream {} + } + } + export = process; }