mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 19:59:02 +08:00
@types/node: fix dns.lookup() definitions (#15900)
* @types/node: fix dns.lookup() definitions * fix optional family argument
This commit is contained in:
committed by
Mohamed Hegazy
parent
d1a979d719
commit
90cd78deeb
@@ -25,6 +25,7 @@ import * as stream from "stream";
|
||||
import * as timers from "timers";
|
||||
import * as repl from "repl";
|
||||
import * as v8 from "v8";
|
||||
import * as dns from "dns";
|
||||
|
||||
// Specifically test buffer module regression.
|
||||
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";
|
||||
@@ -2127,6 +2128,59 @@ namespace repl_tests {
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/// DNS Tests : https://nodejs.org/api/dns.html ///
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
namespace dns_tests {
|
||||
dns.lookup("nodejs.org", (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup("nodejs.org", 4, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup("nodejs.org", 6, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup("nodejs.org", {}, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup(
|
||||
"nodejs.org",
|
||||
{
|
||||
family: 4,
|
||||
hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
all: false
|
||||
},
|
||||
(err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
}
|
||||
);
|
||||
dns.lookup("nodejs.org", {all: true}, (err, addresses) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _address: dns.LookupAddress[] = addresses;
|
||||
});
|
||||
|
||||
function trueOrFalse(): boolean {
|
||||
return Math.random() > 0.5 ? true : false;
|
||||
}
|
||||
dns.lookup("nodejs.org", {all: trueOrFalse()}, (err, addresses, family) => {
|
||||
const _err: NodeJS.ErrnoException = err;
|
||||
const _addresses: string | dns.LookupAddress[] = addresses;
|
||||
const _family: number | undefined = family;
|
||||
});
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* The following tests are the modules not mentioned in document but existed *
|
||||
|
||||
Reference in New Issue
Block a user