Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 24 additions & 11 deletions types/node/dns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,21 @@ declare module "dns" {
* @default false
*/
all?: boolean | undefined;
/**
* When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
* by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
* addresses before IPv4 addresses. Default value is configurable using
* {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder).
* @default `verbatim` (addresses are not reordered)
* @since v22.1.0
*/
order?: "ipv4first" | "ipv6first" | "verbatim" | undefined;
/**
* When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4
* addresses are placed before IPv6 addresses. Default value is configurable using {@link setDefaultResultOrder}
* or [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder).
* @default true
* addresses are placed before IPv6 addresses. This option will be deprecated in favor of `order`. When both are specified,
* `order` has higher precedence. New code should only use `order`. Default value is configurable using {@link setDefaultResultOrder}
* @default true (addresses are not reordered)
* @deprecated Please use `order` option
*/
verbatim?: boolean | undefined;
}
Expand Down Expand Up @@ -663,14 +673,15 @@ declare module "dns" {
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
): void;
/**
* Get the default value for `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
* Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
* The value could be:
*
* * `ipv4first`: for `verbatim` defaulting to `false`.
* * `verbatim`: for `verbatim` defaulting to `true`.
* * `ipv4first`: for `order` defaulting to `ipv4first`.
* * `ipv6first`: for `order` defaulting to `ipv6first`.
* * `verbatim`: for `order` defaulting to `verbatim`.
* @since v18.17.0
*/
export function getDefaultResultOrder(): "ipv4first" | "verbatim";
export function getDefaultResultOrder(): "ipv4first" | "ipv6first" | "verbatim";
/**
* Sets the IP address and port of servers to be used when performing DNS
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
Expand Down Expand Up @@ -717,19 +728,21 @@ declare module "dns" {
*/
export function getServers(): string[];
/**
* Set the default value of `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
* Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
* The value could be:
*
* * `ipv4first`: sets default `verbatim` to `false`.
* * `verbatim`: sets default `verbatim` to `true`.
* * `ipv4first`: sets default `order` to `ipv4first`.
* * `ipv6first`: sets default `order` to `ipv6first`.
* * `verbatim`: sets default `order` to `verbatim`.
*
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using
* [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
* thread won't affect the default dns orders in workers.
* @since v16.4.0, v14.18.0
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
*/
export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
export function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
// Error codes
export const NODATA: "ENODATA";
export const FORMERR: "EFORMERR";
Expand Down
20 changes: 10 additions & 10 deletions types/node/dns/promises.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,20 @@ declare module "dns/promises" {
*/
function setServers(servers: readonly string[]): void;
/**
* Set the default value of `verbatim` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
* The value could be:
* Set the default value of `order` in `dns.lookup()` and `{@link lookup}`. The value could be:
*
* * `ipv4first`: sets default `verbatim` to `false`.
* * `verbatim`: sets default `verbatim` to `true`.
* * `ipv4first`: sets default `order` to `ipv4first`.
* * `ipv6first`: sets default `order` to `ipv6first`.
* * `verbatim`: sets default `order` to `verbatim`.
*
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using
* [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
* thread won't affect the default dns orders in workers.
* The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
* have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
* 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)
* from the main thread won't affect the default dns orders in workers.
* @since v16.4.0, v14.18.0
* @param order must be `'ipv4first'` or `'verbatim'`.
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
*/
function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
// Error codes
const NODATA: "ENODATA";
const FORMERR: "EFORMERR";
Expand Down
4 changes: 2 additions & 2 deletions types/node/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"private": true,
"name": "@types/node",
"version": "22.0.9999",
"version": "22.1.9999",
"nonNpm": "conflict",
"nonNpmDescription": "Node.js",
"projects": [
"https://nodejs.org/"
],
"tsconfigs": ["tsconfig.dom.json", "tsconfig.non-dom.json"],
"dependencies": {
"undici-types": "~6.11.1"
"undici-types": "~6.13.0"
},
"devDependencies": {
"@types/node": "workspace:."
Expand Down
9 changes: 9 additions & 0 deletions types/node/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ declare module "node:test" {
* @default undefined
*/
testNamePatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
/**
* A String, RegExp or a RegExp Array, that can be used to exclude running tests whose
* name matches the provided pattern. Test name patterns are interpreted as JavaScript
* regular expressions. For each test that is executed, any corresponding test hooks,
* such as `beforeEach()`, are also run.
* @default undefined
* @since v22.1.0
*/
testSkipPatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
/**
* The number of milliseconds after which the test execution will fail.
* If unspecified, subtests inherit this value from their parent.
Expand Down
2 changes: 1 addition & 1 deletion types/node/test/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ lookup("nodejs.org", { all: true }, (err, addresses) => {
const _err: NodeJS.ErrnoException | null = err;
const _address: LookupAddress[] = addresses;
});
lookup("nodejs.org", { all: true, verbatim: true }, (err, addresses) => {
lookup("nodejs.org", { all: true, order: "ipv6first" }, (err, addresses) => {
const _err: NodeJS.ErrnoException | null = err;
const _address: LookupAddress[] = addresses;
});
Expand Down
1 change: 1 addition & 0 deletions types/node/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ run({
timeout: 100,
inspectPort: () => 8081,
testNamePatterns: ["executed", /^core-/],
testSkipPatterns: ["excluded", /^lib-/],
only: true,
setup: (reporter) => {
// $ExpectType TestsStream
Expand Down
14 changes: 14 additions & 0 deletions types/node/test/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ import * as url from "node:url";

{
let path: string = url.fileURLToPath("file://test");
path = url.fileURLToPath("file://test", { windows: false });
path = url.fileURLToPath("file://test", { windows: true });
path = url.fileURLToPath(new url.URL("file://test"));
path = url.fileURLToPath(new url.URL("file://test"), { windows: false });
path = url.fileURLToPath(new url.URL("file://test"), { windows: true });
}

{
let path: url.URL = url.pathToFileURL("file://test");
path = url.pathToFileURL("file://test", { windows: false });
path = url.pathToFileURL("file://test", { windows: true });
}

{
Expand All @@ -206,3 +212,11 @@ import * as url from "node:url";
const urlSearchParams1: URLSearchParams = new url.URLSearchParams();
const urlSearchParams2: url.URLSearchParams = new URLSearchParams();
}

{
const isValid = url.URL.canParse('/foo', 'https://example.org/');
isValid; // $ExpectType boolean

const parsedUrl = url.URL.parse('/foo', 'https://example.org/');
parsedUrl; // $ExpectType URL | null
}
29 changes: 27 additions & 2 deletions types/node/url.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ declare module "url" {
interface UrlWithStringQuery extends Url {
query: string | null;
}
interface FileUrlToPathOptions {
/**
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
* @default undefined
* @since v22.1.0
*/
windows?: boolean | undefined;
}
interface PathToFileUrlOptions {
/**
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
* @default undefined
* @since v22.1.0
*/
windows?: boolean | undefined;
}
/**
* The `url.parse()` method takes a URL string, parses it, and returns a URL
* object.
Expand Down Expand Up @@ -298,7 +314,7 @@ declare module "url" {
* @param url The file URL string or URL object to convert to a path.
* @return The fully-resolved platform-specific Node.js file path.
*/
function fileURLToPath(url: string | URL): string;
function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string;
/**
* This function ensures that `path` is resolved absolutely, and that the URL
* control characters are correctly encoded when converting into a File URL.
Expand All @@ -316,7 +332,7 @@ declare module "url" {
* @param path The path to convert to a File URL.
* @return The file URL object.
*/
function pathToFileURL(path: string): URL;
function pathToFileURL(path: string, options?: PathToFileUrlOptions): URL;
/**
* This utility function converts a URL object into an ordinary options object as
* expected by the `http.request()` and `https.request()` APIs.
Expand Down Expand Up @@ -429,6 +445,15 @@ declare module "url" {
* @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.
*/
static canParse(input: string, base?: string): boolean;
/**
* 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.
* Returns `null` if `input` is not a valid.
* @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
* `converted to a string` first.
* @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.
* @since v22.1.0
*/
static parse(input: string, base?: string): URL | null;
constructor(input: string | { toString: () => string }, base?: string | URL);
/**
* Gets and sets the fragment portion of the URL.
Expand Down