[@types/node] use canonical type for stdin, stdout, stderr (#38826)

* use canonical type for stdin, stdout, stderr

* Add missing namespace

* Remove import types usage
This commit is contained in:
Ben Lichtman
2019-10-03 13:28:09 -07:00
committed by Ryan Cavanaugh
parent b095948b8a
commit ccd64ce329
3 changed files with 19 additions and 25 deletions
-25
View File
@@ -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];
}
+7
View File
@@ -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;
}
////////////////////////////////////////////////////
+12
View File
@@ -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;
}