Skip to content

Commit 9cbafb7

Browse files
authored
🤖 Merge PR DefinitelyTyped#74817 Fix JSDoc for overloaded Node stream APIs by @pimterry
1 parent 3ce1ffe commit 9cbafb7

File tree

8 files changed

+192
-24
lines changed

8 files changed

+192
-24
lines changed

types/node/net.d.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,14 @@ declare module "node:net" {
116116
* See `Writable` stream `write()` method for more
117117
* information.
118118
* @since v0.1.90
119-
* @param [encoding='utf8'] Only used when data is `string`.
120119
*/
121120
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
121+
/**
122+
* Sends data on the socket, with an explicit encoding for string data.
123+
* @see {@link Socket.write} for full details.
124+
* @since v0.1.90
125+
* @param [encoding='utf8'] Only used when data is `string`.
126+
*/
122127
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
123128
/**
124129
* Initiate a connection on a given socket.
@@ -358,12 +363,26 @@ declare module "node:net" {
358363
*
359364
* See `writable.end()` for further details.
360365
* @since v0.1.90
361-
* @param [encoding='utf8'] Only used when data is `string`.
362366
* @param callback Optional callback for when the socket is finished.
363367
* @return The socket itself.
364368
*/
365369
end(callback?: () => void): this;
370+
/**
371+
* Half-closes the socket, with one final chunk of data.
372+
* @see {@link Socket.end} for full details.
373+
* @since v0.1.90
374+
* @param callback Optional callback for when the socket is finished.
375+
* @return The socket itself.
376+
*/
366377
end(buffer: Uint8Array | string, callback?: () => void): this;
378+
/**
379+
* Half-closes the socket, with one final chunk of data.
380+
* @see {@link Socket.end} for full details.
381+
* @since v0.1.90
382+
* @param [encoding='utf8'] Only used when data is `string`.
383+
* @param callback Optional callback for when the socket is finished.
384+
* @return The socket itself.
385+
*/
367386
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
368387
// #region InternalEventEmitter
369388
addListener<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;

types/node/stream.d.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,20 @@ declare module "node:stream" {
899899
* @since v0.9.4
900900
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
901901
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
902-
* @param [encoding='utf8'] The encoding, if `chunk` is a string.
903902
* @param callback Callback for when this chunk of data is flushed.
904903
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
905904
*/
906905
write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean;
906+
/**
907+
* Writes data to the stream, with an explicit encoding for string data.
908+
* @see {@link Writable.write} for full details.
909+
* @since v0.9.4
910+
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
911+
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
912+
* @param encoding The encoding, if `chunk` is a string.
913+
* @param callback Callback for when this chunk of data is flushed.
914+
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
915+
*/
907916
write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean;
908917
/**
909918
* The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream.
@@ -928,13 +937,27 @@ declare module "node:stream" {
928937
* // Writing more now is not allowed!
929938
* ```
930939
* @since v0.9.4
940+
* @param cb Callback for when the stream is finished.
941+
*/
942+
end(cb?: () => void): this;
943+
/**
944+
* Signals that no more data will be written, with one final chunk of data.
945+
* @see {@link Writable.end} for full details.
946+
* @since v0.9.4
931947
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
932948
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
933-
* @param encoding The encoding if `chunk` is a string
934-
* @param callback Callback for when the stream is finished.
949+
* @param cb Callback for when the stream is finished.
935950
*/
936-
end(cb?: () => void): this;
937951
end(chunk: any, cb?: () => void): this;
952+
/**
953+
* Signals that no more data will be written, with one final chunk of data.
954+
* @see {@link Writable.end} for full details.
955+
* @since v0.9.4
956+
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
957+
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
958+
* @param encoding The encoding if `chunk` is a string
959+
* @param cb Callback for when the stream is finished.
960+
*/
938961
end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
939962
/**
940963
* The `writable.cork()` method forces all written data to be buffered in memory.

types/node/v20/net.d.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ declare module "net" {
111111
* See `Writable` stream `write()` method for more
112112
* information.
113113
* @since v0.1.90
114-
* @param [encoding='utf8'] Only used when data is `string`.
115114
*/
116115
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
116+
/**
117+
* Sends data on the socket, with an explicit encoding for string data.
118+
* @see {@link Socket.write} for full details.
119+
* @since v0.1.90
120+
* @param [encoding='utf8'] Only used when data is `string`.
121+
*/
117122
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
118123
/**
119124
* Initiate a connection on a given socket.
@@ -353,12 +358,26 @@ declare module "net" {
353358
*
354359
* See `writable.end()` for further details.
355360
* @since v0.1.90
356-
* @param [encoding='utf8'] Only used when data is `string`.
357361
* @param callback Optional callback for when the socket is finished.
358362
* @return The socket itself.
359363
*/
360364
end(callback?: () => void): this;
365+
/**
366+
* Half-closes the socket, with one final chunk of data.
367+
* @see {@link Socket.end} for full details.
368+
* @since v0.1.90
369+
* @param callback Optional callback for when the socket is finished.
370+
* @return The socket itself.
371+
*/
361372
end(buffer: Uint8Array | string, callback?: () => void): this;
373+
/**
374+
* Half-closes the socket, with one final chunk of data.
375+
* @see {@link Socket.end} for full details.
376+
* @since v0.1.90
377+
* @param [encoding='utf8'] Only used when data is `string`.
378+
* @param callback Optional callback for when the socket is finished.
379+
* @return The socket itself.
380+
*/
362381
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
363382
/**
364383
* events.EventEmitter

types/node/v20/stream.d.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,11 +865,20 @@ declare module "stream" {
865865
* @since v0.9.4
866866
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
867867
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
868-
* @param [encoding='utf8'] The encoding, if `chunk` is a string.
869868
* @param callback Callback for when this chunk of data is flushed.
870869
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
871870
*/
872871
write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean;
872+
/**
873+
* Writes data to the stream, with an explicit encoding for string data.
874+
* @see {@link Writable.write} for full details.
875+
* @since v0.9.4
876+
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
877+
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
878+
* @param encoding The encoding, if `chunk` is a string.
879+
* @param callback Callback for when this chunk of data is flushed.
880+
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
881+
*/
873882
write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean;
874883
/**
875884
* The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream.
@@ -894,13 +903,27 @@ declare module "stream" {
894903
* // Writing more now is not allowed!
895904
* ```
896905
* @since v0.9.4
906+
* @param cb Callback for when the stream is finished.
907+
*/
908+
end(cb?: () => void): this;
909+
/**
910+
* Signals that no more data will be written, with one final chunk of data.
911+
* @see {@link Writable.end} for full details.
912+
* @since v0.9.4
897913
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
898914
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
899-
* @param encoding The encoding if `chunk` is a string
900-
* @param callback Callback for when the stream is finished.
915+
* @param cb Callback for when the stream is finished.
901916
*/
902-
end(cb?: () => void): this;
903917
end(chunk: any, cb?: () => void): this;
918+
/**
919+
* Signals that no more data will be written, with one final chunk of data.
920+
* @see {@link Writable.end} for full details.
921+
* @since v0.9.4
922+
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
923+
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
924+
* @param encoding The encoding if `chunk` is a string
925+
* @param cb Callback for when the stream is finished.
926+
*/
904927
end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
905928
/**
906929
* The `writable.cork()` method forces all written data to be buffered in memory.

types/node/v22/net.d.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,14 @@ declare module "net" {
108108
* See `Writable` stream `write()` method for more
109109
* information.
110110
* @since v0.1.90
111-
* @param [encoding='utf8'] Only used when data is `string`.
112111
*/
113112
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
113+
/**
114+
* Sends data on the socket, with an explicit encoding for string data.
115+
* @see {@link Socket.write} for full details.
116+
* @since v0.1.90
117+
* @param [encoding='utf8'] Only used when data is `string`.
118+
*/
114119
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
115120
/**
116121
* Initiate a connection on a given socket.
@@ -350,12 +355,26 @@ declare module "net" {
350355
*
351356
* See `writable.end()` for further details.
352357
* @since v0.1.90
353-
* @param [encoding='utf8'] Only used when data is `string`.
354358
* @param callback Optional callback for when the socket is finished.
355359
* @return The socket itself.
356360
*/
357361
end(callback?: () => void): this;
362+
/**
363+
* Half-closes the socket, with one final chunk of data.
364+
* @see {@link Socket.end} for full details.
365+
* @since v0.1.90
366+
* @param callback Optional callback for when the socket is finished.
367+
* @return The socket itself.
368+
*/
358369
end(buffer: Uint8Array | string, callback?: () => void): this;
370+
/**
371+
* Half-closes the socket, with one final chunk of data.
372+
* @see {@link Socket.end} for full details.
373+
* @since v0.1.90
374+
* @param [encoding='utf8'] Only used when data is `string`.
375+
* @param callback Optional callback for when the socket is finished.
376+
* @return The socket itself.
377+
*/
359378
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
360379
/**
361380
* events.EventEmitter

types/node/v22/stream.d.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,20 @@ declare module "stream" {
858858
* @since v0.9.4
859859
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
860860
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
861-
* @param [encoding='utf8'] The encoding, if `chunk` is a string.
862861
* @param callback Callback for when this chunk of data is flushed.
863862
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
864863
*/
865864
write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean;
865+
/**
866+
* Writes data to the stream, with an explicit encoding for string data.
867+
* @see {@link Writable.write} for full details.
868+
* @since v0.9.4
869+
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
870+
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
871+
* @param encoding The encoding, if `chunk` is a string.
872+
* @param callback Callback for when this chunk of data is flushed.
873+
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
874+
*/
866875
write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean;
867876
/**
868877
* The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream.
@@ -887,13 +896,27 @@ declare module "stream" {
887896
* // Writing more now is not allowed!
888897
* ```
889898
* @since v0.9.4
899+
* @param cb Callback for when the stream is finished.
900+
*/
901+
end(cb?: () => void): this;
902+
/**
903+
* Signals that no more data will be written, with one final chunk of data.
904+
* @see {@link Writable.end} for full details.
905+
* @since v0.9.4
890906
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
891907
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
892-
* @param encoding The encoding if `chunk` is a string
893-
* @param callback Callback for when the stream is finished.
908+
* @param cb Callback for when the stream is finished.
894909
*/
895-
end(cb?: () => void): this;
896910
end(chunk: any, cb?: () => void): this;
911+
/**
912+
* Signals that no more data will be written, with one final chunk of data.
913+
* @see {@link Writable.end} for full details.
914+
* @since v0.9.4
915+
* @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
916+
* {TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
917+
* @param encoding The encoding if `chunk` is a string
918+
* @param cb Callback for when the stream is finished.
919+
*/
897920
end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
898921
/**
899922
* The `writable.cork()` method forces all written data to be buffered in memory.

types/node/v24/net.d.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ declare module "net" {
105105
* See `Writable` stream `write()` method for more
106106
* information.
107107
* @since v0.1.90
108-
* @param [encoding='utf8'] Only used when data is `string`.
109108
*/
110109
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
110+
/**
111+
* Sends data on the socket, with an explicit encoding for string data.
112+
* @see {@link Socket.write} for full details.
113+
* @since v0.1.90
114+
* @param [encoding='utf8'] Only used when data is `string`.
115+
*/
111116
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
112117
/**
113118
* Initiate a connection on a given socket.
@@ -347,12 +352,26 @@ declare module "net" {
347352
*
348353
* See `writable.end()` for further details.
349354
* @since v0.1.90
350-
* @param [encoding='utf8'] Only used when data is `string`.
351355
* @param callback Optional callback for when the socket is finished.
352356
* @return The socket itself.
353357
*/
354358
end(callback?: () => void): this;
359+
/**
360+
* Half-closes the socket, with one final chunk of data.
361+
* @see {@link Socket.end} for full details.
362+
* @since v0.1.90
363+
* @param callback Optional callback for when the socket is finished.
364+
* @return The socket itself.
365+
*/
355366
end(buffer: Uint8Array | string, callback?: () => void): this;
367+
/**
368+
* Half-closes the socket, with one final chunk of data.
369+
* @see {@link Socket.end} for full details.
370+
* @since v0.1.90
371+
* @param [encoding='utf8'] Only used when data is `string`.
372+
* @param callback Optional callback for when the socket is finished.
373+
* @return The socket itself.
374+
*/
356375
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
357376
/**
358377
* events.EventEmitter

0 commit comments

Comments
 (0)