mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
@types/node: update dns.resolve* declarations (#16320)
* @types/node: update dns.resolve* declarations Fixes: #11151 * review fixes
This commit is contained in:
committed by
Mohamed Hegazy
parent
d41436966c
commit
65989c0d61
100
types/node/index.d.ts
vendored
100
types/node/index.d.ts
vendored
@@ -1886,11 +1886,6 @@ declare module "url" {
|
||||
}
|
||||
|
||||
declare module "dns" {
|
||||
export interface MxRecord {
|
||||
exchange: string,
|
||||
priority: number
|
||||
}
|
||||
|
||||
// Supported getaddrinfo flags.
|
||||
export const ADDRCONFIG: number;
|
||||
export const V4MAPPED: number;
|
||||
@@ -1914,22 +1909,87 @@ declare module "dns" {
|
||||
family: number;
|
||||
}
|
||||
|
||||
export function lookup(domain: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
|
||||
export function lookup(domain: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
|
||||
export function lookup(domain: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void;
|
||||
export function lookup(domain: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void;
|
||||
export function lookup(domain: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
|
||||
export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
|
||||
export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
|
||||
export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void;
|
||||
export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void;
|
||||
export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
|
||||
|
||||
export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[];
|
||||
export function resolveTxt(domain: string, callback: (err: Error, addresses: string[][]) => void): string[][];
|
||||
export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
|
||||
export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[];
|
||||
export interface ResolveOptions {
|
||||
ttl: boolean;
|
||||
}
|
||||
|
||||
export interface ResolveWithTtlOptions extends ResolveOptions {
|
||||
ttl: true;
|
||||
}
|
||||
|
||||
export interface RecordWithTtl {
|
||||
address: string;
|
||||
ttl: number;
|
||||
}
|
||||
|
||||
export interface MxRecord {
|
||||
priority: number;
|
||||
exchange: string;
|
||||
}
|
||||
|
||||
export interface NaptrRecord {
|
||||
flags: string;
|
||||
service: string;
|
||||
regexp: string;
|
||||
replacement: string;
|
||||
order: number;
|
||||
preference: number;
|
||||
}
|
||||
|
||||
export interface SoaRecord {
|
||||
nsname: string;
|
||||
hostmaster: string;
|
||||
serial: number;
|
||||
refresh: number;
|
||||
retry: number;
|
||||
expire: number;
|
||||
minttl: number;
|
||||
}
|
||||
|
||||
export interface SrvRecord {
|
||||
priority: number;
|
||||
weight: number;
|
||||
port: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void;
|
||||
|
||||
export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException, addresses: RecordWithTtl[]) => void): void;
|
||||
export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||
|
||||
export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException, addresses: RecordWithTtl[]) => void): void;
|
||||
export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||
|
||||
export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void;
|
||||
export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void;
|
||||
export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
|
||||
export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void;
|
||||
export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void;
|
||||
export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void;
|
||||
|
||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void;
|
||||
export function setServers(servers: string[]): void;
|
||||
|
||||
//Error codes
|
||||
|
||||
@@ -2179,6 +2179,45 @@ namespace dns_tests {
|
||||
const _addresses: string | dns.LookupAddress[] = addresses;
|
||||
const _family: number | undefined = family;
|
||||
});
|
||||
|
||||
dns.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "A", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "AAAA", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "MX", (err, addresses) => {
|
||||
const _addresses: dns.MxRecord[] = addresses;
|
||||
});
|
||||
|
||||
dns.resolve4("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve4("nodejs.org", {ttl: true}, (err, addresses) => {
|
||||
const _addresses: dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
{
|
||||
const ttl = false;
|
||||
dns.resolve4("nodejs.org", {ttl: ttl}, (err, addresses) => {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
|
||||
dns.resolve6("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve6("nodejs.org", {ttl: true}, (err, addresses) => {
|
||||
const _addresses: dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
{
|
||||
const ttl = false;
|
||||
dns.resolve6("nodejs.org", {ttl: ttl}, (err, addresses) => {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user