Update types for public-ip to v2.4

This commit is contained in:
Dimitri Benin
2018-12-13 00:19:35 +01:00
parent d161f79adb
commit b2e8151b0d
2 changed files with 15 additions and 10 deletions

View File

@@ -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 <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function v4(options?: Options): Promise<string>;
export function v6(options?: Options): Promise<string>;
export function v4(options?: Options): CancelablePromise<string>;
export function v6(options?: Options): CancelablePromise<string>;
export interface Options {
https?: boolean;
timeout?: number;
}
export type CancelablePromise<T> = Promise<T> & {
cancel(): void;
};

View File

@@ -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();