diff --git a/types/public-ip/index.d.ts b/types/public-ip/index.d.ts index 463a1a2d18..58fb81aa93 100644 --- a/types/public-ip/index.d.ts +++ b/types/public-ip/index.d.ts @@ -1,12 +1,16 @@ -// Type definitions for public-ip 2.3 +// Type definitions for public-ip 2.4 // Project: https://github.com/sindresorhus/public-ip#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export function v4(options?: Options): Promise; -export function v6(options?: Options): Promise; +export function v4(options?: Options): CancelablePromise; +export function v6(options?: Options): CancelablePromise; export interface Options { https?: boolean; timeout?: number; } + +export type CancelablePromise = Promise & { + cancel(): void; +}; diff --git a/types/public-ip/public-ip-tests.ts b/types/public-ip/public-ip-tests.ts index e7e0540bbe..6e5983bc99 100644 --- a/types/public-ip/public-ip-tests.ts +++ b/types/public-ip/public-ip-tests.ts @@ -1,16 +1,17 @@ import * as publicIp from 'public-ip'; -let str: string; publicIp.v4().then(ip => { - str = ip; + ip; // $ExpectType string }); -publicIp.v4({https: false, timeout: 10}).then(ip => { - str = ip; +publicIp.v4({ https: false, timeout: 10 }).then(ip => { + ip; // $ExpectType string }); +publicIp.v4().cancel(); publicIp.v6().then(ip => { - str = ip; + ip; // $ExpectType string }); -publicIp.v6({https: false, timeout: 10}).then(ip => { - str = ip; +publicIp.v6({ https: false, timeout: 10 }).then(ip => { + ip; // $ExpectType string }); +publicIp.v6().cancel();