Skip to content

Commit d8849ac

Browse files
authored
🤖 Merge PR DefinitelyTyped#71663 [node] Update typings to v22.13.0 by @Renegade334
1 parent 3cb78b3 commit d8849ac

20 files changed

+381
-37
lines changed

types/node/assert.d.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,59 @@ declare module "assert" {
956956
* @since v13.6.0, v12.16.0
957957
*/
958958
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
959+
/**
960+
* `assert.partialDeepStrictEqual()` Asserts the equivalence between the `actual` and `expected` parameters through a
961+
* deep comparison, ensuring that all properties in the `expected` parameter are
962+
* present in the `actual` parameter with equivalent values, not allowing type coercion.
963+
* The main difference with `assert.deepStrictEqual()` is that `assert.partialDeepStrictEqual()` does not require
964+
* all properties in the `actual` parameter to be present in the `expected` parameter.
965+
* This method should always pass the same test cases as `assert.deepStrictEqual()`, behaving as a super set of it.
966+
*
967+
* ```js
968+
* import assert from 'node:assert';
969+
*
970+
* assert.partialDeepStrictEqual({ a: 1, b: 2 }, { a: 1, b: 2 });
971+
* // OK
972+
*
973+
* assert.partialDeepStrictEqual({ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } });
974+
* // OK
975+
*
976+
* assert.partialDeepStrictEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
977+
* // OK
978+
*
979+
* assert.partialDeepStrictEqual(new Set(['value1', 'value2']), new Set(['value1', 'value2']));
980+
* // OK
981+
*
982+
* assert.partialDeepStrictEqual(new Map([['key1', 'value1']]), new Map([['key1', 'value1']]));
983+
* // OK
984+
*
985+
* assert.partialDeepStrictEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 3]));
986+
* // OK
987+
*
988+
* assert.partialDeepStrictEqual(/abc/, /abc/);
989+
* // OK
990+
*
991+
* assert.partialDeepStrictEqual([{ a: 5 }, { b: 5 }], [{ a: 5 }]);
992+
* // OK
993+
*
994+
* assert.partialDeepStrictEqual(new Set([{ a: 1 }, { b: 1 }]), new Set([{ a: 1 }]));
995+
* // OK
996+
*
997+
* assert.partialDeepStrictEqual(new Date(0), new Date(0));
998+
* // OK
999+
*
1000+
* assert.partialDeepStrictEqual({ a: 1 }, { a: 1, b: 2 });
1001+
* // AssertionError
1002+
*
1003+
* assert.partialDeepStrictEqual({ a: 1, b: '2' }, { a: 1, b: 2 });
1004+
* // AssertionError
1005+
*
1006+
* assert.partialDeepStrictEqual({ a: { b: 2 } }, { a: { b: '2' } });
1007+
* // AssertionError
1008+
* ```
1009+
* @since v22.13.0
1010+
*/
1011+
function partialDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
9591012
/**
9601013
* In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example,
9611014
* {@link deepEqual} will behave like {@link deepStrictEqual}.

types/node/buffer.buffer.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ declare module "buffer" {
107107
*
108108
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
109109
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
110-
* truncated to `totalLength`.
110+
* truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
111+
* less than `totalLength`, the remaining space is filled with zeros.
111112
*
112113
* ```js
113114
* import { Buffer } from 'node:buffer';

types/node/dgram.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/dgram.js)
2727
*/
2828
declare module "dgram" {
29-
import { AddressInfo } from "node:net";
29+
import { AddressInfo, BlockList } from "node:net";
3030
import * as dns from "node:dns";
3131
import { Abortable, EventEmitter } from "node:events";
3232
interface RemoteInfo {
@@ -59,6 +59,8 @@ declare module "dgram" {
5959
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
6060
) => void)
6161
| undefined;
62+
receiveBlockList?: BlockList | undefined;
63+
sendBlockList?: BlockList | undefined;
6264
}
6365
/**
6466
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram

types/node/http.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ declare module "http" {
223223
path?: string | null | undefined;
224224
port?: number | string | null | undefined;
225225
protocol?: string | null | undefined;
226+
setDefaultHeaders?: boolean | undefined;
226227
setHost?: boolean | undefined;
227228
signal?: AbortSignal | undefined;
228229
socketPath?: string | undefined;

types/node/module.d.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,80 @@ declare module "module" {
168168
options?: RegisterOptions<Data>,
169169
): void;
170170
function register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
171+
interface StripTypeScriptTypesOptions {
172+
/**
173+
* Possible values are:
174+
* * `'strip'` Only strip type annotations without performing the transformation of TypeScript features.
175+
* * `'transform'` Strip type annotations and transform TypeScript features to JavaScript.
176+
* @default 'strip'
177+
*/
178+
mode?: "strip" | "transform" | undefined;
179+
/**
180+
* Only when `mode` is `'transform'`, if `true`, a source map
181+
* will be generated for the transformed code.
182+
* @default false
183+
*/
184+
sourceMap?: boolean | undefined;
185+
/**
186+
* Specifies the source url used in the source map.
187+
*/
188+
sourceUrl?: string | undefined;
189+
}
190+
/**
191+
* `module.stripTypeScriptTypes()` removes type annotations from TypeScript code. It
192+
* can be used to strip type annotations from TypeScript code before running it
193+
* with `vm.runInContext()` or `vm.compileFunction()`.
194+
* By default, it will throw an error if the code contains TypeScript features
195+
* that require transformation such as `Enums`,
196+
* see [type-stripping](https://nodejs.org/docs/latest-v22.x/api/typescript.md#type-stripping) for more information.
197+
* When mode is `'transform'`, it also transforms TypeScript features to JavaScript,
198+
* see [transform TypeScript features](https://nodejs.org/docs/latest-v22.x/api/typescript.md#typescript-features) for more information.
199+
* When mode is `'strip'`, source maps are not generated, because locations are preserved.
200+
* If `sourceMap` is provided, when mode is `'strip'`, an error will be thrown.
201+
*
202+
* _WARNING_: The output of this function should not be considered stable across Node.js versions,
203+
* due to changes in the TypeScript parser.
204+
*
205+
* ```js
206+
* import { stripTypeScriptTypes } from 'node:module';
207+
* const code = 'const a: number = 1;';
208+
* const strippedCode = stripTypeScriptTypes(code);
209+
* console.log(strippedCode);
210+
* // Prints: const a = 1;
211+
* ```
212+
*
213+
* If `sourceUrl` is provided, it will be used appended as a comment at the end of the output:
214+
*
215+
* ```js
216+
* import { stripTypeScriptTypes } from 'node:module';
217+
* const code = 'const a: number = 1;';
218+
* const strippedCode = stripTypeScriptTypes(code, { mode: 'strip', sourceUrl: 'source.ts' });
219+
* console.log(strippedCode);
220+
* // Prints: const a = 1\n\n//# sourceURL=source.ts;
221+
* ```
222+
*
223+
* When `mode` is `'transform'`, the code is transformed to JavaScript:
224+
*
225+
* ```js
226+
* import { stripTypeScriptTypes } from 'node:module';
227+
* const code = `
228+
* namespace MathUtil {
229+
* export const add = (a: number, b: number) => a + b;
230+
* }`;
231+
* const strippedCode = stripTypeScriptTypes(code, { mode: 'transform', sourceMap: true });
232+
* console.log(strippedCode);
233+
* // Prints:
234+
* // var MathUtil;
235+
* // (function(MathUtil) {
236+
* // MathUtil.add = (a, b)=>a + b;
237+
* // })(MathUtil || (MathUtil = {}));
238+
* // # sourceMappingURL=data:application/json;base64, ...
239+
* ```
240+
* @since v22.13.0
241+
* @param code The code to strip type annotations from.
242+
* @returns The code with type annotations stripped.
243+
*/
244+
function stripTypeScriptTypes(code: string, options?: StripTypeScriptTypesOptions): string;
171245
/* eslint-enable @definitelytyped/no-unnecessary-generics */
172246
/**
173247
* The `module.syncBuiltinESMExports()` method updates all the live bindings for

types/node/net.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ declare module "net" {
6565
* @since v18.13.0
6666
*/
6767
autoSelectFamilyAttemptTimeout?: number | undefined;
68+
blockList?: BlockList | undefined;
6869
}
6970
interface IpcSocketConnectOpts {
7071
path: string;
@@ -535,6 +536,15 @@ declare module "net" {
535536
* @since v18.17.0, v20.1.0
536537
*/
537538
highWaterMark?: number | undefined;
539+
/**
540+
* `blockList` can be used for disabling inbound
541+
* access to specific IP addresses, IP ranges, or IP subnets. This does not
542+
* work if the server is behind a reverse proxy, NAT, etc. because the address
543+
* checked against the block list is the address of the proxy, or the one
544+
* specified by the NAT.
545+
* @since v22.13.0
546+
*/
547+
blockList?: BlockList | undefined;
538548
}
539549
interface DropArgument {
540550
localAddress?: string;
@@ -786,6 +796,12 @@ declare module "net" {
786796
* @since v15.0.0, v14.18.0
787797
*/
788798
rules: readonly string[];
799+
/**
800+
* Returns `true` if the `value` is a `net.BlockList`.
801+
* @since v22.13.0
802+
* @param value Any JS value
803+
*/
804+
static isBlockList(value: unknown): value is BlockList;
789805
}
790806
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
791807
timeout?: number | undefined;
@@ -998,6 +1014,14 @@ declare module "net" {
9981014
* @since v15.14.0, v14.18.0
9991015
*/
10001016
readonly flowlabel: number;
1017+
/**
1018+
* @since v22.13.0
1019+
* @param input An input string containing an IP address and optional port,
1020+
* e.g. `123.1.2.3:1234` or `[1::1]:1234`.
1021+
* @returns Returns a `SocketAddress` if parsing was successful.
1022+
* Otherwise returns `undefined`.
1023+
*/
1024+
static parse(input: string): SocketAddress | undefined;
10011025
}
10021026
}
10031027
declare module "node:net" {

types/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "22.12.9999",
4+
"version": "22.13.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [

types/node/perf_hooks.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,11 @@ declare module "perf_hooks" {
594594
buffered?: boolean | undefined;
595595
},
596596
): void;
597+
/**
598+
* @since v16.0.0
599+
* @returns Current list of entries stored in the performance observer, emptying it out.
600+
*/
601+
takeRecords(): PerformanceEntry[];
597602
}
598603
/**
599604
* Provides detailed network timing data regarding the loading of an application's resources.

types/node/process.d.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ declare module "process" {
186186
readonly inspector: boolean;
187187
/**
188188
* A boolean value that is `true` if the current Node.js build includes support for IPv6.
189+
*
190+
* Since all Node.js builds have IPv6 support, this value is always `true`.
189191
* @since v0.5.3
192+
* @deprecated This property is always true, and any checks based on it are redundant.
190193
*/
191194
readonly ipv6: boolean;
192195
/**
@@ -202,17 +205,29 @@ declare module "process" {
202205
readonly tls: boolean;
203206
/**
204207
* A boolean value that is `true` if the current Node.js build includes support for ALPN in TLS.
208+
*
209+
* In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional ALPN support.
210+
* This value is therefore identical to that of `process.features.tls`.
205211
* @since v4.8.0
212+
* @deprecated Use `process.features.tls` instead.
206213
*/
207214
readonly tls_alpn: boolean;
208215
/**
209216
* A boolean value that is `true` if the current Node.js build includes support for OCSP in TLS.
217+
*
218+
* In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional OCSP support.
219+
* This value is therefore identical to that of `process.features.tls`.
210220
* @since v0.11.13
221+
* @deprecated Use `process.features.tls` instead.
211222
*/
212223
readonly tls_ocsp: boolean;
213224
/**
214225
* A boolean value that is `true` if the current Node.js build includes support for SNI in TLS.
226+
*
227+
* In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional SNI support.
228+
* This value is therefore identical to that of `process.features.tls`.
215229
* @since v0.5.3
230+
* @deprecated Use `process.features.tls` instead.
216231
*/
217232
readonly tls_sni: boolean;
218233
/**
@@ -223,8 +238,10 @@ declare module "process" {
223238
readonly typescript: "strip" | "transform" | false;
224239
/**
225240
* A boolean value that is `true` if the current Node.js build includes support for libuv.
226-
* Since it's currently not possible to build Node.js without libuv, this value is always `true`.
241+
*
242+
* Since it's not possible to build Node.js without libuv, this value is always `true`.
227243
* @since v0.5.3
244+
* @deprecated This property is always true, and any checks based on it are redundant.
228245
*/
229246
readonly uv: boolean;
230247
}
@@ -1676,7 +1693,7 @@ declare module "process" {
16761693
*/
16771694
nextTick(callback: Function, ...args: any[]): void;
16781695
/**
1679-
* This API is available through the [--experimental-permission](https://nodejs.org/api/cli.html#--experimental-permission) flag.
1696+
* This API is available through the [--permission](https://nodejs.org/api/cli.html#--permission) flag.
16801697
*
16811698
* `process.permission` is an object whose methods are used to manage permissions for the current process.
16821699
* Additional documentation is available in the [Permission Model](https://nodejs.org/api/permissions.html#permission-model).

types/node/sea.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,5 @@ declare module "node:sea" {
149149
* writes to the returned array buffer is likely to result in a crash.
150150
* @since v20.12.0
151151
*/
152-
function getRawAsset(key: AssetKey): string | ArrayBuffer;
152+
function getRawAsset(key: AssetKey): ArrayBuffer;
153153
}

0 commit comments

Comments
 (0)