[public-ip] add typings (#18752)

This commit is contained in:
Dimitri Benin
2017-08-08 22:35:03 +02:00
committed by Mohamed Hegazy
parent 3e4bc214f3
commit d4bb1bd1e4
4 changed files with 51 additions and 0 deletions

12
types/public-ip/index.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
// Type definitions for public-ip 2.3
// 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 interface Options {
https?: boolean;
timeout?: number;
}

View File

@@ -0,0 +1,16 @@
import * as publicIp from 'public-ip';
let str: string;
publicIp.v4().then(ip => {
str = ip;
});
publicIp.v4({https: false, timeout: 10}).then(ip => {
str = ip;
});
publicIp.v6().then(ip => {
str = ip;
});
publicIp.v6({https: false, timeout: 10}).then(ip => {
str = ip;
});

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"public-ip-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }