mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
node: add std* file descriptors constants (#46034)
* node: add file descriptors * adjust types from other modules
This commit is contained in:
parent
6ebf2f46d2
commit
806c044994
@ -5,5 +5,5 @@ const stream = fs.createReadStream('package.json');
|
||||
|
||||
// $ExpectType ReadStream
|
||||
destroy(stream);
|
||||
// $ExpectType WriteStream
|
||||
// $ExpectType WriteStream & { fd: 2; }
|
||||
destroy(process.stderr);
|
||||
|
||||
@ -35,7 +35,7 @@ mp.end('bar', encoding);
|
||||
mp.end('bar', encoding, () => {});
|
||||
mp.resume();
|
||||
mp.pause();
|
||||
mp.pipe(process.stdout); // $ExpectType WriteStream
|
||||
mp.pipe(process.stdout); // $ExpectType WriteStream & { fd: 1; }
|
||||
|
||||
mp.on('data', chunk => {
|
||||
chunk; // $ExpectType any
|
||||
|
||||
12
types/node/process.d.ts
vendored
12
types/node/process.d.ts
vendored
@ -174,12 +174,18 @@ declare module "process" {
|
||||
/**
|
||||
* Can also be a tty.WriteStream, not typed due to limitations.
|
||||
*/
|
||||
stdout: WriteStream;
|
||||
stdout: WriteStream & {
|
||||
fd: 1;
|
||||
};
|
||||
/**
|
||||
* Can also be a tty.WriteStream, not typed due to limitations.
|
||||
*/
|
||||
stderr: WriteStream;
|
||||
stdin: ReadStream;
|
||||
stderr: WriteStream & {
|
||||
fd: 2;
|
||||
};
|
||||
stdin: ReadStream & {
|
||||
fd: 0;
|
||||
};
|
||||
openStdin(): Socket;
|
||||
argv: string[];
|
||||
argv0: string;
|
||||
|
||||
@ -32,6 +32,10 @@ import { EventEmitter } from "events";
|
||||
const listeners = process.listeners('uncaughtException');
|
||||
const oldHandler = listeners[listeners.length - 1];
|
||||
process.addListener('uncaughtException', oldHandler);
|
||||
|
||||
const stdInFd = process.stdin.fd;
|
||||
const stdOutFd = process.stdout.fd;
|
||||
const stdErrorFd = process.stderr.fd;
|
||||
}
|
||||
{
|
||||
function myCb(err: Error): void {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user