diff --git a/index.d.ts b/index.d.ts index bc6ba0b..1f30e63 100644 --- a/index.d.ts +++ b/index.d.ts @@ -99,10 +99,10 @@ export default class CacheableLookup { /** * @see https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback */ - lookup(hostname: string, family: IPFamily, callback: (error: NodeJS.ErrnoException, address: string, family: IPFamily) => void): void; - lookup(hostname: string, callback: (error: NodeJS.ErrnoException, address: string, family: IPFamily) => void): void; - lookup(hostname: string, options: LookupOptions & {all: true}, callback: (error: NodeJS.ErrnoException, result: ReadonlyArray) => void): void; - lookup(hostname: string, options: LookupOptions, callback: (error: NodeJS.ErrnoException, address: string, family: IPFamily) => void): void; + lookup(hostname: string, family: IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: IPFamily) => void): void; + lookup(hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: IPFamily) => void): void; + lookup(hostname: string, options: LookupOptions & {all: true}, callback: (error: NodeJS.ErrnoException | null, result: ReadonlyArray) => void): void; + lookup(hostname: string, options: LookupOptions, callback: (error: NodeJS.ErrnoException | null, address: string, family: IPFamily) => void): void; /** * The asynchronous version of `dns.lookup(…)`. */ diff --git a/index.test-d.ts b/index.test-d.ts index 17547c9..678c9e2 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -37,22 +37,25 @@ import CacheableLookup, {EntryObject} from '.'; expectType>(await cacheable.lookupAsync('localhost', {all: true})); cacheable.lookup('localhost', 6, (error, address, family) => { - expectType(error); + expectType(error); expectType(address); expectType<4 | 6>(family); }); cacheable.lookup('localhost', {all: false}, (error, address, family) => { - expectType(error); + expectType(error); expectType(address); expectType<4 | 6>(family); }); cacheable.lookup('localhost', {all: true}, (error, results) => { - expectType(error); + expectType(error); expectType>(results); }); + // @types/node has invalid typings :( + // expectType(lookup); + expectType>(await cacheable.query('localhost')); expectType>(await cacheable.queryAndCache('localhost'));