mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
[@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:
committed by
Ryan Cavanaugh
parent
b095948b8a
commit
ccd64ce329
Vendored
-25
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+12
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user