🤖 Merge PR #61273 @types/node: add missing v18 stable properties for streams by @rangoo94

* fix(@types/node): add missing stable properties for streams

* fix(@types/readable-stream): adjust to match valid streams

* fix(@types/levelup): fix definitions across TypeScript versions
This commit is contained in:
Dawid Rusnak
2022-07-17 22:38:59 +02:00
committed by GitHub
parent 65ae463766
commit 4908704786
4 changed files with 35 additions and 2 deletions

View File

@@ -108,7 +108,7 @@ declare namespace levelup {
isOpen(): boolean;
isClosed(): boolean;
readonly status: "new" | "opening" | "open" | "closing" | "closed";
readonly status: "closed" | "open" | "opening" | "new" | "closing";
isOperational(): boolean;
createReadStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream;

View File

@@ -61,7 +61,7 @@ db.isOpen();
// $ExpectType boolean
db.isClosed();
// $ExpectType "new" | "opening" | "open" | "closing" | "closed" || "open" | "opening" | "closed" | "new" | "closing"
// $ExpectType "closed" | "open" | "opening" | "new" | "closing"
db.status;
// $ExpectType boolean

View File

@@ -126,6 +126,16 @@ declare module 'stream' {
* @since v18.0.0
*/
destroyed: boolean;
/**
* Is true after 'close' has been emitted.
* @since v8.0.0
*/
readonly closed: boolean;
/**
* Returns error if the stream has been destroyed with an error.
* @since v18.0.0
*/
readonly errored: Error | null;
constructor(opts?: ReadableOptions);
_construct?(callback: (error?: Error | null) => void): void;
_read(size: number): void;
@@ -554,6 +564,21 @@ declare module 'stream' {
* @since v8.0.0
*/
destroyed: boolean;
/**
* Is true after 'close' has been emitted.
* @since v8.0.0
*/
readonly closed: boolean;
/**
* Returns error if the stream has been destroyed with an error.
* @since v18.0.0
*/
readonly errored: Error | null;
/**
* Is `true` if the stream's buffer has been full and stream will emit 'drain'.
* @since v15.2.0, v14.17.0
*/
readonly writableNeedDrain: boolean;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
_writev?(
@@ -820,6 +845,9 @@ declare module 'stream' {
readonly writableLength: number;
readonly writableObjectMode: boolean;
readonly writableCorked: number;
readonly writableNeedDrain: boolean;
readonly closed: boolean;
readonly errored: Error | null;
/**
* If `false` then the stream will automatically end the writable side when the
* readable side ends. Set initially by the `allowHalfOpen` constructor option,

View File

@@ -56,6 +56,8 @@ declare class _Readable implements _IReadable {
readonly readableFlowing: boolean | null;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly closed: boolean;
readonly errored: Error | null;
_read(size: number): void;
read(size?: number): any;
setEncoding(encoding: string): this;
@@ -406,6 +408,9 @@ declare namespace _Readable {
writable: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly closed: boolean;
readonly errored: Error | null;
readonly writableNeedDrain: boolean;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;