diff --git a/types/node/net.d.ts b/types/node/net.d.ts index 1e57e18f24f8b7..9af5e3d9eba134 100644 --- a/types/node/net.d.ts +++ b/types/node/net.d.ts @@ -18,8 +18,8 @@ declare module "net" { import * as dns from "node:dns"; type LookupFunction = ( hostname: string, - options: dns.LookupAllOptions, - callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void, + options: dns.LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void, ) => void; interface AddressInfo { address: string; diff --git a/types/node/test/http.ts b/types/node/test/http.ts index 21dfb89829e334..298be35ff9a3fd 100644 --- a/types/node/test/http.ts +++ b/types/node/test/http.ts @@ -673,6 +673,11 @@ import * as url from "node:url"; cb(null, [{ address: "", family: 1 }]); }, }); + http.request({ + lookup: (hostname, options, cb) => { + cb(null, "", 1); + }, + }); } { diff --git a/types/node/test/https.ts b/types/node/test/https.ts index c1c38e0a850ced..46915e2335525c 100644 --- a/types/node/test/https.ts +++ b/types/node/test/https.ts @@ -604,4 +604,9 @@ import * as url from "node:url"; cb(null, [{ address: "", family: 1 }]); }, }); + https.request({ + lookup: (hostname, options, cb) => { + cb(null, "", 1); + }, + }); } diff --git a/types/node/test/net.ts b/types/node/test/net.ts index 3bf5ad73c15a0b..9f0d48c5bf55da 100644 --- a/types/node/test/net.ts +++ b/types/node/test/net.ts @@ -1,5 +1,5 @@ import { Socket } from "node:dgram"; -import { LookupAddress, LookupAllOptions } from "node:dns"; +import { LookupAddress, LookupOptions } from "node:dns"; import * as net from "node:net"; { @@ -70,6 +70,30 @@ import * as net from "node:net"; _socket.destroySoon(); } +{ + // lookup callback can be either an array of LookupAddress or a single address and family + const tcpConnectLookupAllOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, + ): void => { + callback(null, [{ address: "", family: 1 }]); + }, + port: 80, + }; + const tcpConnectLookupOneOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void => { + callback(null, "", 1); + }, + port: 80, + }; +} + { const constructorOpts: net.SocketConstructorOpts = { fd: 1, @@ -109,7 +133,7 @@ import * as net from "node:net"; localPort: 1234, lookup: ( _hostname: string, - _options: LookupAllOptions, + _options: LookupOptions, _callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, ): void => { // nothing diff --git a/types/node/ts4.8/net.d.ts b/types/node/ts4.8/net.d.ts index 1e57e18f24f8b7..9af5e3d9eba134 100644 --- a/types/node/ts4.8/net.d.ts +++ b/types/node/ts4.8/net.d.ts @@ -18,8 +18,8 @@ declare module "net" { import * as dns from "node:dns"; type LookupFunction = ( hostname: string, - options: dns.LookupAllOptions, - callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void, + options: dns.LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void, ) => void; interface AddressInfo { address: string; diff --git a/types/node/ts4.8/test/http.ts b/types/node/ts4.8/test/http.ts index f0ac60957c7cc9..46036eb8173478 100644 --- a/types/node/ts4.8/test/http.ts +++ b/types/node/ts4.8/test/http.ts @@ -646,6 +646,11 @@ import * as url from "node:url"; cb(null, [{ address: "", family: 1 }]); }, }); + http.request({ + lookup: (hostname, options, cb) => { + cb(null, "", 1); + }, + }); } { diff --git a/types/node/ts4.8/test/https.ts b/types/node/ts4.8/test/https.ts index c1c38e0a850ced..46915e2335525c 100644 --- a/types/node/ts4.8/test/https.ts +++ b/types/node/ts4.8/test/https.ts @@ -604,4 +604,9 @@ import * as url from "node:url"; cb(null, [{ address: "", family: 1 }]); }, }); + https.request({ + lookup: (hostname, options, cb) => { + cb(null, "", 1); + }, + }); } diff --git a/types/node/ts4.8/test/net.ts b/types/node/ts4.8/test/net.ts index 11dad9611fff84..8db2ff1c6e161b 100644 --- a/types/node/ts4.8/test/net.ts +++ b/types/node/ts4.8/test/net.ts @@ -1,5 +1,5 @@ import { Socket } from "node:dgram"; -import { LookupAddress, LookupAllOptions } from "node:dns"; +import { LookupAddress, LookupOptions } from "node:dns"; import * as net from "node:net"; { @@ -70,6 +70,30 @@ import * as net from "node:net"; _socket.destroySoon(); } +{ + // lookup callback can be either an array of LookupAddress or a single address and family + const tcpConnectLookupAllOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, + ): void => { + callback(null, [{ address: "", family: 1 }]); + }, + port: 80, + }; + const tcpConnectLookupOneOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void => { + callback(null, "", 1); + }, + port: 80, + }; +} + { const constructorOpts: net.SocketConstructorOpts = { fd: 1, @@ -109,7 +133,7 @@ import * as net from "node:net"; localPort: 1234, lookup: ( _hostname: string, - _options: LookupAllOptions, + _options: LookupOptions, _callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, ): void => { // nothing diff --git a/types/node/v18/net.d.ts b/types/node/v18/net.d.ts index 782b8915b8ce6c..e17f0212e7c870 100644 --- a/types/node/v18/net.d.ts +++ b/types/node/v18/net.d.ts @@ -18,8 +18,8 @@ declare module "net" { import * as dns from "node:dns"; type LookupFunction = ( hostname: string, - options: dns.LookupOneOptions, - callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + options: dns.LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void, ) => void; interface AddressInfo { address: string; diff --git a/types/node/v18/test/net.ts b/types/node/v18/test/net.ts index eec1fbded5072d..fcba4d93a2f578 100644 --- a/types/node/v18/test/net.ts +++ b/types/node/v18/test/net.ts @@ -1,5 +1,5 @@ import { Socket } from "node:dgram"; -import { LookupOneOptions } from "node:dns"; +import { LookupAddress, LookupOptions } from "node:dns"; import * as net from "node:net"; { @@ -70,6 +70,30 @@ import * as net from "node:net"; _socket.destroySoon(); } +{ + // lookup callback can be either an array of LookupAddress or a single address and family + const tcpConnectLookupAllOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, + ): void => { + callback(null, [{ address: "", family: 1 }]); + }, + port: 80, + }; + const tcpConnectLookupOneOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void => { + callback(null, "", 1); + }, + port: 80, + }; +} + { const constructorOpts: net.SocketConstructorOpts = { fd: 1, @@ -109,7 +133,7 @@ import * as net from "node:net"; localPort: 1234, lookup: ( _hostname: string, - _options: LookupOneOptions, + _options: LookupOptions, _callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, ): void => { // nothing diff --git a/types/node/v18/ts4.8/net.d.ts b/types/node/v18/ts4.8/net.d.ts index 782b8915b8ce6c..e17f0212e7c870 100644 --- a/types/node/v18/ts4.8/net.d.ts +++ b/types/node/v18/ts4.8/net.d.ts @@ -18,8 +18,8 @@ declare module "net" { import * as dns from "node:dns"; type LookupFunction = ( hostname: string, - options: dns.LookupOneOptions, - callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + options: dns.LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void, ) => void; interface AddressInfo { address: string; diff --git a/types/node/v18/ts4.8/test/net.ts b/types/node/v18/ts4.8/test/net.ts index eec1fbded5072d..fcba4d93a2f578 100644 --- a/types/node/v18/ts4.8/test/net.ts +++ b/types/node/v18/ts4.8/test/net.ts @@ -1,5 +1,5 @@ import { Socket } from "node:dgram"; -import { LookupOneOptions } from "node:dns"; +import { LookupAddress, LookupOptions } from "node:dns"; import * as net from "node:net"; { @@ -70,6 +70,30 @@ import * as net from "node:net"; _socket.destroySoon(); } +{ + // lookup callback can be either an array of LookupAddress or a single address and family + const tcpConnectLookupAllOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, + ): void => { + callback(null, [{ address: "", family: 1 }]); + }, + port: 80, + }; + const tcpConnectLookupOneOpts: net.TcpSocketConnectOpts = { + lookup: ( + _hostname: string, + _options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void => { + callback(null, "", 1); + }, + port: 80, + }; +} + { const constructorOpts: net.SocketConstructorOpts = { fd: 1, @@ -109,7 +133,7 @@ import * as net from "node:net"; localPort: 1234, lookup: ( _hostname: string, - _options: LookupOneOptions, + _options: LookupOptions, _callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, ): void => { // nothing