Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node] Update typings to v22.13.0 #71663

Merged
merged 22 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7cb0eb8
assert: add partialDeepStrictEqual
Renegade334 Jan 13, 2025
8f724ee
src,lib: stabilize permission model
Renegade334 Jan 13, 2025
1d3a93b
dgram: support blocklist in udp
Renegade334 Jan 16, 2025
467905c
doc: stabilize util.styleText
Renegade334 Jan 16, 2025
809cb8c
module: add module.stripTypeScriptTypes
Renegade334 Jan 16, 2025
868a35f
net: support blockList in net.connect
Renegade334 Jan 16, 2025
b5500f4
net: support blocklist for net.Server
Renegade334 Jan 16, 2025
125fc54
net: add SocketAddress.parse
Renegade334 Jan 16, 2025
800df5c
net: add net.BlockList.isBlockList(value)
Renegade334 Jan 16, 2025
3b921f2
process: deprecate features.{ipv6,uv} and features.tls_*
Renegade334 Jan 16, 2025
41d123b
sqlite: aggregate constants in a single property
Renegade334 Jan 16, 2025
62dab82
sqlite: add StatementSync.prototype.iterate method
Renegade334 Jan 16, 2025
b093197
util: add sourcemap support to getCallSites
Renegade334 Jan 16, 2025
4299efd
buffer: document concat zero-fill
Renegade334 Jan 23, 2025
c8bdb3a
doc: clarify util.aborted resource usage
Renegade334 Jan 23, 2025
5bbdaeb
doc: sea.getRawAsset(key) always returns an ArrayBuffer
Renegade334 Jan 23, 2025
5967e16
doc: add doc for PerformanceObserver.takeRecords()
Renegade334 Jan 23, 2025
0d98ac3
http: add setDefaultHeaders option to http.request
Renegade334 Jan 23, 2025
9677186
sqlite: add support for custom functions
Renegade334 Jan 23, 2025
753be5f
sqlite: support db.loadExtension
Renegade334 Jan 23, 2025
86eb959
test_runner: mark snapshot testing as stable
Renegade334 Jan 23, 2025
848b6d0
Update version to v22.13.x
Renegade334 Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions types/node/assert.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,59 @@ declare module "assert" {
* @since v13.6.0, v12.16.0
*/
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
/**
* `assert.partialDeepStrictEqual()` Asserts the equivalence between the `actual` and `expected` parameters through a
* deep comparison, ensuring that all properties in the `expected` parameter are
* present in the `actual` parameter with equivalent values, not allowing type coercion.
* The main difference with `assert.deepStrictEqual()` is that `assert.partialDeepStrictEqual()` does not require
* all properties in the `actual` parameter to be present in the `expected` parameter.
* This method should always pass the same test cases as `assert.deepStrictEqual()`, behaving as a super set of it.
*
* ```js
* import assert from 'node:assert';
*
* assert.partialDeepStrictEqual({ a: 1, b: 2 }, { a: 1, b: 2 });
* // OK
*
* assert.partialDeepStrictEqual({ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } });
* // OK
*
* assert.partialDeepStrictEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
* // OK
*
* assert.partialDeepStrictEqual(new Set(['value1', 'value2']), new Set(['value1', 'value2']));
* // OK
*
* assert.partialDeepStrictEqual(new Map([['key1', 'value1']]), new Map([['key1', 'value1']]));
* // OK
*
* assert.partialDeepStrictEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 3]));
* // OK
*
* assert.partialDeepStrictEqual(/abc/, /abc/);
* // OK
*
* assert.partialDeepStrictEqual([{ a: 5 }, { b: 5 }], [{ a: 5 }]);
* // OK
*
* assert.partialDeepStrictEqual(new Set([{ a: 1 }, { b: 1 }]), new Set([{ a: 1 }]));
* // OK
*
* assert.partialDeepStrictEqual(new Date(0), new Date(0));
* // OK
*
* assert.partialDeepStrictEqual({ a: 1 }, { a: 1, b: 2 });
* // AssertionError
*
* assert.partialDeepStrictEqual({ a: 1, b: '2' }, { a: 1, b: 2 });
* // AssertionError
*
* assert.partialDeepStrictEqual({ a: { b: 2 } }, { a: { b: '2' } });
* // AssertionError
* ```
* @since v22.13.0
*/
function partialDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
/**
* In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example,
* {@link deepEqual} will behave like {@link deepStrictEqual}.
Expand Down
3 changes: 2 additions & 1 deletion types/node/buffer.buffer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ declare module "buffer" {
*
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
* truncated to `totalLength`.
* truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
* less than `totalLength`, the remaining space is filled with zeros.
*
* ```js
* import { Buffer } from 'node:buffer';
Expand Down
4 changes: 3 additions & 1 deletion types/node/dgram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/dgram.js)
*/
declare module "dgram" {
import { AddressInfo } from "node:net";
import { AddressInfo, BlockList } from "node:net";
import * as dns from "node:dns";
import { Abortable, EventEmitter } from "node:events";
interface RemoteInfo {
Expand Down Expand Up @@ -59,6 +59,8 @@ declare module "dgram" {
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
) => void)
| undefined;
receiveBlockList?: BlockList | undefined;
sendBlockList?: BlockList | undefined;
}
/**
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
Expand Down
1 change: 1 addition & 0 deletions types/node/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ declare module "http" {
path?: string | null | undefined;
port?: number | string | null | undefined;
protocol?: string | null | undefined;
setDefaultHeaders?: boolean | undefined;
setHost?: boolean | undefined;
signal?: AbortSignal | undefined;
socketPath?: string | undefined;
Expand Down
74 changes: 74 additions & 0 deletions types/node/module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,80 @@ declare module "module" {
options?: RegisterOptions<Data>,
): void;
function register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
interface StripTypeScriptTypesOptions {
/**
* Possible values are:
* * `'strip'` Only strip type annotations without performing the transformation of TypeScript features.
* * `'transform'` Strip type annotations and transform TypeScript features to JavaScript.
* @default 'strip'
*/
mode?: "strip" | "transform" | undefined;
/**
* Only when `mode` is `'transform'`, if `true`, a source map
* will be generated for the transformed code.
* @default false
*/
sourceMap?: boolean | undefined;
/**
* Specifies the source url used in the source map.
*/
sourceUrl?: string | undefined;
}
/**
* `module.stripTypeScriptTypes()` removes type annotations from TypeScript code. It
* can be used to strip type annotations from TypeScript code before running it
* with `vm.runInContext()` or `vm.compileFunction()`.
* By default, it will throw an error if the code contains TypeScript features
* that require transformation such as `Enums`,
* see [type-stripping](https://nodejs.org/docs/latest-v22.x/api/typescript.md#type-stripping) for more information.
* When mode is `'transform'`, it also transforms TypeScript features to JavaScript,
* see [transform TypeScript features](https://nodejs.org/docs/latest-v22.x/api/typescript.md#typescript-features) for more information.
* When mode is `'strip'`, source maps are not generated, because locations are preserved.
* If `sourceMap` is provided, when mode is `'strip'`, an error will be thrown.
*
* _WARNING_: The output of this function should not be considered stable across Node.js versions,
* due to changes in the TypeScript parser.
*
* ```js
* import { stripTypeScriptTypes } from 'node:module';
* const code = 'const a: number = 1;';
* const strippedCode = stripTypeScriptTypes(code);
* console.log(strippedCode);
* // Prints: const a = 1;
* ```
*
* If `sourceUrl` is provided, it will be used appended as a comment at the end of the output:
*
* ```js
* import { stripTypeScriptTypes } from 'node:module';
* const code = 'const a: number = 1;';
* const strippedCode = stripTypeScriptTypes(code, { mode: 'strip', sourceUrl: 'source.ts' });
* console.log(strippedCode);
* // Prints: const a = 1\n\n//# sourceURL=source.ts;
* ```
*
* When `mode` is `'transform'`, the code is transformed to JavaScript:
*
* ```js
* import { stripTypeScriptTypes } from 'node:module';
* const code = `
* namespace MathUtil {
* export const add = (a: number, b: number) => a + b;
* }`;
* const strippedCode = stripTypeScriptTypes(code, { mode: 'transform', sourceMap: true });
* console.log(strippedCode);
* // Prints:
* // var MathUtil;
* // (function(MathUtil) {
* // MathUtil.add = (a, b)=>a + b;
* // })(MathUtil || (MathUtil = {}));
* // # sourceMappingURL=data:application/json;base64, ...
* ```
* @since v22.13.0
* @param code The code to strip type annotations from.
* @returns The code with type annotations stripped.
*/
function stripTypeScriptTypes(code: string, options?: StripTypeScriptTypesOptions): string;
/* eslint-enable @definitelytyped/no-unnecessary-generics */
/**
* The `module.syncBuiltinESMExports()` method updates all the live bindings for
Expand Down
24 changes: 24 additions & 0 deletions types/node/net.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ declare module "net" {
* @since v18.13.0
*/
autoSelectFamilyAttemptTimeout?: number | undefined;
blockList?: BlockList | undefined;
}
interface IpcSocketConnectOpts {
path: string;
Expand Down Expand Up @@ -535,6 +536,15 @@ declare module "net" {
* @since v18.17.0, v20.1.0
*/
highWaterMark?: number | undefined;
/**
* `blockList` can be used for disabling inbound
* access to specific IP addresses, IP ranges, or IP subnets. This does not
* work if the server is behind a reverse proxy, NAT, etc. because the address
* checked against the block list is the address of the proxy, or the one
* specified by the NAT.
* @since v22.13.0
*/
blockList?: BlockList | undefined;
}
interface DropArgument {
localAddress?: string;
Expand Down Expand Up @@ -786,6 +796,12 @@ declare module "net" {
* @since v15.0.0, v14.18.0
*/
rules: readonly string[];
/**
* Returns `true` if the `value` is a `net.BlockList`.
* @since v22.13.0
* @param value Any JS value
*/
static isBlockList(value: unknown): value is BlockList;
}
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
timeout?: number | undefined;
Expand Down Expand Up @@ -998,6 +1014,14 @@ declare module "net" {
* @since v15.14.0, v14.18.0
*/
readonly flowlabel: number;
/**
* @since v22.13.0
* @param input An input string containing an IP address and optional port,
* e.g. `123.1.2.3:1234` or `[1::1]:1234`.
* @returns Returns a `SocketAddress` if parsing was successful.
* Otherwise returns `undefined`.
*/
static parse(input: string): SocketAddress | undefined;
}
}
declare module "node:net" {
Expand Down
2 changes: 1 addition & 1 deletion types/node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/node",
"version": "22.12.9999",
"version": "22.13.9999",
"nonNpm": "conflict",
"nonNpmDescription": "Node.js",
"projects": [
Expand Down
5 changes: 5 additions & 0 deletions types/node/perf_hooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ declare module "perf_hooks" {
buffered?: boolean | undefined;
},
): void;
/**
* @since v16.0.0
* @returns Current list of entries stored in the performance observer, emptying it out.
*/
takeRecords(): PerformanceEntry[];
}
/**
* Provides detailed network timing data regarding the loading of an application's resources.
Expand Down
21 changes: 19 additions & 2 deletions types/node/process.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ declare module "process" {
readonly inspector: boolean;
/**
* A boolean value that is `true` if the current Node.js build includes support for IPv6.
*
* Since all Node.js builds have IPv6 support, this value is always `true`.
* @since v0.5.3
* @deprecated This property is always true, and any checks based on it are redundant.
*/
readonly ipv6: boolean;
/**
Expand All @@ -202,17 +205,29 @@ declare module "process" {
readonly tls: boolean;
/**
* A boolean value that is `true` if the current Node.js build includes support for ALPN in TLS.
*
* In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional ALPN support.
* This value is therefore identical to that of `process.features.tls`.
* @since v4.8.0
* @deprecated Use `process.features.tls` instead.
*/
readonly tls_alpn: boolean;
/**
* A boolean value that is `true` if the current Node.js build includes support for OCSP in TLS.
*
* In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional OCSP support.
* This value is therefore identical to that of `process.features.tls`.
* @since v0.11.13
* @deprecated Use `process.features.tls` instead.
*/
readonly tls_ocsp: boolean;
/**
* A boolean value that is `true` if the current Node.js build includes support for SNI in TLS.
*
* In Node.js 11.0.0 and later versions, the OpenSSL dependencies feature unconditional SNI support.
* This value is therefore identical to that of `process.features.tls`.
* @since v0.5.3
* @deprecated Use `process.features.tls` instead.
*/
readonly tls_sni: boolean;
/**
Expand All @@ -223,8 +238,10 @@ declare module "process" {
readonly typescript: "strip" | "transform" | false;
/**
* A boolean value that is `true` if the current Node.js build includes support for libuv.
* Since it's currently not possible to build Node.js without libuv, this value is always `true`.
*
* Since it's not possible to build Node.js without libuv, this value is always `true`.
* @since v0.5.3
* @deprecated This property is always true, and any checks based on it are redundant.
*/
readonly uv: boolean;
}
Expand Down Expand Up @@ -1676,7 +1693,7 @@ declare module "process" {
*/
nextTick(callback: Function, ...args: any[]): void;
/**
* This API is available through the [--experimental-permission](https://nodejs.org/api/cli.html#--experimental-permission) flag.
* This API is available through the [--permission](https://nodejs.org/api/cli.html#--permission) flag.
*
* `process.permission` is an object whose methods are used to manage permissions for the current process.
* Additional documentation is available in the [Permission Model](https://nodejs.org/api/permissions.html#permission-model).
Expand Down
2 changes: 1 addition & 1 deletion types/node/sea.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ declare module "node:sea" {
* writes to the returned array buffer is likely to result in a crash.
* @since v20.12.0
*/
function getRawAsset(key: AssetKey): string | ArrayBuffer;
function getRawAsset(key: AssetKey): ArrayBuffer;
}
Loading
Loading