@types/node: fix dns.lookup() definitions (#15900)

* @types/node: fix dns.lookup() definitions

* fix optional family argument
This commit is contained in:
ikokostya
2017-05-03 22:09:15 +03:00
committed by Mohamed Hegazy
parent d1a979d719
commit 90cd78deeb
6 changed files with 249 additions and 6 deletions

View File

@@ -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 *