Skip to content

Commit 7138fc2

Browse files
committed
[node] Update typings to v22.1.0
https://github.com/nodejs/node/releases/tag/v22.1.0 - dns: add order option and support ipv6first - lib, url: add a windows option to path parsing - test_runner: add --test-skip-pattern cli option - url: implement parse method for safer URL parsing - deps: update undici to 6.13.0
1 parent e376c2b commit 7138fc2

File tree

8 files changed

+88
-26
lines changed

8 files changed

+88
-26
lines changed

types/node/dns.d.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,21 @@ declare module "dns" {
8080
* @default false
8181
*/
8282
all?: boolean | undefined;
83+
/**
84+
* When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
85+
* by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
86+
* addresses before IPv4 addresses. Default value is configurable using
87+
* {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder).
88+
* @default `verbatim` (addresses are not reordered)
89+
* @since v22.1.0
90+
*/
91+
order?: "ipv4first" | "ipv6first" | "verbatim" | undefined;
8392
/**
8493
* When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4
85-
* addresses are placed before IPv6 addresses. Default value is configurable using {@link setDefaultResultOrder}
86-
* or [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder).
87-
* @default true
94+
* addresses are placed before IPv6 addresses. This option will be deprecated in favor of `order`. When both are specified,
95+
* `order` has higher precedence. New code should only use `order`. Default value is configurable using {@link setDefaultResultOrder}
96+
* @default true (addresses are not reordered)
97+
* @deprecated Please use `order` option
8898
*/
8999
verbatim?: boolean | undefined;
90100
}
@@ -663,14 +673,15 @@ declare module "dns" {
663673
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
664674
): void;
665675
/**
666-
* Get the default value for `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
676+
* Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
667677
* The value could be:
668678
*
669-
* * `ipv4first`: for `verbatim` defaulting to `false`.
670-
* * `verbatim`: for `verbatim` defaulting to `true`.
679+
* * `ipv4first`: for `order` defaulting to `ipv4first`.
680+
* * `ipv6first`: for `order` defaulting to `ipv6first`.
681+
* * `verbatim`: for `order` defaulting to `verbatim`.
671682
* @since v18.17.0
672683
*/
673-
export function getDefaultResultOrder(): "ipv4first" | "verbatim";
684+
export function getDefaultResultOrder(): "ipv4first" | "ipv6first" | "verbatim";
674685
/**
675686
* Sets the IP address and port of servers to be used when performing DNS
676687
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
@@ -717,19 +728,21 @@ declare module "dns" {
717728
*/
718729
export function getServers(): string[];
719730
/**
720-
* Set the default value of `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
731+
* Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
721732
* The value could be:
722733
*
723-
* * `ipv4first`: sets default `verbatim` to `false`.
724-
* * `verbatim`: sets default `verbatim` to `true`.
734+
* * `ipv4first`: sets default `order` to `ipv4first`.
735+
* * `ipv6first`: sets default `order` to `ipv6first`.
736+
* * `verbatim`: sets default `order` to `verbatim`.
725737
*
726738
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
727739
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using
728740
* [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
729741
* thread won't affect the default dns orders in workers.
730742
* @since v16.4.0, v14.18.0
743+
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
731744
*/
732-
export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
745+
export function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
733746
// Error codes
734747
export const NODATA: "ENODATA";
735748
export const FORMERR: "EFORMERR";

types/node/dns/promises.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,20 @@ declare module "dns/promises" {
346346
*/
347347
function setServers(servers: readonly string[]): void;
348348
/**
349-
* Set the default value of `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
350-
* The value could be:
349+
* Set the default value of `order` in `dns.lookup()` and `{@link lookup}`. The value could be:
351350
*
352-
* * `ipv4first`: sets default `verbatim` to `false`.
353-
* * `verbatim`: sets default `verbatim` to `true`.
351+
* * `ipv4first`: sets default `order` to `ipv4first`.
352+
* * `ipv6first`: sets default `order` to `ipv6first`.
353+
* * `verbatim`: sets default `order` to `verbatim`.
354354
*
355-
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
356-
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using
357-
* [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
358-
* thread won't affect the default dns orders in workers.
355+
* The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
356+
* have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
357+
* When using [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
358+
* from the main thread won't affect the default dns orders in workers.
359359
* @since v16.4.0, v14.18.0
360-
* @param order must be `'ipv4first'` or `'verbatim'`.
360+
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
361361
*/
362-
function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
362+
function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
363363
// Error codes
364364
const NODATA: "ENODATA";
365365
const FORMERR: "EFORMERR";

types/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "22.0.9999",
4+
"version": "22.1.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [
88
"https://nodejs.org/"
99
],
1010
"tsconfigs": ["tsconfig.dom.json", "tsconfig.non-dom.json"],
1111
"dependencies": {
12-
"undici-types": "~6.11.1"
12+
"undici-types": "~6.13.0"
1313
},
1414
"devDependencies": {
1515
"@types/node": "workspace:."

types/node/test.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ declare module "node:test" {
342342
* @default undefined
343343
*/
344344
testNamePatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
345+
/**
346+
* A String, RegExp or a RegExp Array, that can be used to exclude running tests whose
347+
* name matches the provided pattern. Test name patterns are interpreted as JavaScript
348+
* regular expressions. For each test that is executed, any corresponding test hooks,
349+
* such as `beforeEach()`, are also run.
350+
* @default undefined
351+
* @since v22.1.0
352+
*/
353+
testSkipPatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
345354
/**
346355
* The number of milliseconds after which the test execution will fail.
347356
* If unspecified, subtests inherit this value from their parent.

types/node/test/dns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ lookup("nodejs.org", { all: true }, (err, addresses) => {
7777
const _err: NodeJS.ErrnoException | null = err;
7878
const _address: LookupAddress[] = addresses;
7979
});
80-
lookup("nodejs.org", { all: true, verbatim: true }, (err, addresses) => {
80+
lookup("nodejs.org", { all: true, order: "ipv6first" }, (err, addresses) => {
8181
const _err: NodeJS.ErrnoException | null = err;
8282
const _address: LookupAddress[] = addresses;
8383
});

types/node/test/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ run({
3838
timeout: 100,
3939
inspectPort: () => 8081,
4040
testNamePatterns: ["executed", /^core-/],
41+
testSkipPatterns: ["excluded", /^lib-/],
4142
only: true,
4243
setup: (reporter) => {
4344
// $ExpectType TestsStream

types/node/test/url.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,17 @@ import * as url from "node:url";
187187

188188
{
189189
let path: string = url.fileURLToPath("file://test");
190+
path = url.fileURLToPath("file://test", { windows: false });
191+
path = url.fileURLToPath("file://test", { windows: true });
190192
path = url.fileURLToPath(new url.URL("file://test"));
193+
path = url.fileURLToPath(new url.URL("file://test"), { windows: false });
194+
path = url.fileURLToPath(new url.URL("file://test"), { windows: true });
191195
}
192196

193197
{
194198
let path: url.URL = url.pathToFileURL("file://test");
199+
path = url.pathToFileURL("file://test", { windows: false });
200+
path = url.pathToFileURL("file://test", { windows: true });
195201
}
196202

197203
{
@@ -206,3 +212,11 @@ import * as url from "node:url";
206212
const urlSearchParams1: URLSearchParams = new url.URLSearchParams();
207213
const urlSearchParams2: url.URLSearchParams = new URLSearchParams();
208214
}
215+
216+
{
217+
const isValid = url.URL.canParse('/foo', 'https://example.org/');
218+
isValid; // $ExpectType boolean
219+
220+
const parsedUrl = url.URL.parse('/foo', 'https://example.org/');
221+
parsedUrl; // $ExpectType URL | null
222+
}

types/node/url.d.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ declare module "url" {
4646
interface UrlWithStringQuery extends Url {
4747
query: string | null;
4848
}
49+
interface FileUrlToPathOptions {
50+
/**
51+
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
52+
* @default undefined
53+
* @since v22.1.0
54+
*/
55+
windows?: boolean | undefined;
56+
}
57+
interface PathToFileUrlOptions {
58+
/**
59+
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
60+
* @default undefined
61+
* @since v22.1.0
62+
*/
63+
windows?: boolean | undefined;
64+
}
4965
/**
5066
* The `url.parse()` method takes a URL string, parses it, and returns a URL
5167
* object.
@@ -298,7 +314,7 @@ declare module "url" {
298314
* @param url The file URL string or URL object to convert to a path.
299315
* @return The fully-resolved platform-specific Node.js file path.
300316
*/
301-
function fileURLToPath(url: string | URL): string;
317+
function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string;
302318
/**
303319
* This function ensures that `path` is resolved absolutely, and that the URL
304320
* control characters are correctly encoded when converting into a File URL.
@@ -316,7 +332,7 @@ declare module "url" {
316332
* @param path The path to convert to a File URL.
317333
* @return The file URL object.
318334
*/
319-
function pathToFileURL(path: string): URL;
335+
function pathToFileURL(path: string, options?: PathToFileUrlOptions): URL;
320336
/**
321337
* This utility function converts a URL object into an ordinary options object as
322338
* expected by the `http.request()` and `https.request()` APIs.
@@ -429,6 +445,15 @@ declare module "url" {
429445
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
430446
*/
431447
static canParse(input: string, base?: string): boolean;
448+
/**
449+
* Parses a string as a URL. If `base` is provided, it will be used as the base URL for the purpose of resolving non-absolute `input` URLs.
450+
* Returns `null` if `input` is not a valid.
451+
* @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
452+
* `converted to a string` first.
453+
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
454+
* @since v22.1.0
455+
*/
456+
static parse(input: string, base?: string): URL | null;
432457
constructor(input: string | { toString: () => string }, base?: string | URL);
433458
/**
434459
* Gets and sets the fragment portion of the URL.

0 commit comments

Comments
 (0)