From 46dd4e8815a6b79bbf006945ec6b693d147ca688 Mon Sep 17 00:00:00 2001 From: Vladyslav Khrapov Date: Mon, 8 Apr 2019 14:23:13 +0300 Subject: [PATCH 1/3] Add localtunnel type definitions --- types/localtunnel/index.d.ts | 44 ++++++++++++++++++++++++++ types/localtunnel/localtunnel-tests.ts | 10 ++++++ types/localtunnel/tsconfig.json | 23 ++++++++++++++ types/localtunnel/tslint.json | 1 + 4 files changed, 78 insertions(+) create mode 100644 types/localtunnel/index.d.ts create mode 100644 types/localtunnel/localtunnel-tests.ts create mode 100644 types/localtunnel/tsconfig.json create mode 100644 types/localtunnel/tslint.json diff --git a/types/localtunnel/index.d.ts b/types/localtunnel/index.d.ts new file mode 100644 index 0000000000..219075ed31 --- /dev/null +++ b/types/localtunnel/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for localtunnel v1.9.1 +// Project: https://github.com/vladhrapov/typings +// Definitions by: Vladyslav Khrapov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function localtunnel( + port: number, + callback: localtunnel.TunnelCallback +): localtunnel.Tunnel; + +declare function localtunnel( + port: number, + opt: localtunnel.TunnelConfig, + callback: localtunnel.TunnelCallback +): localtunnel.Tunnel; + +declare namespace localtunnel { + export type TunnelCallback = ( + err: string, + tunnel?: localtunnel.Tunnel + ) => void; + + export interface TunnelConfig { + host?: string; + subdomain?: string; + port?: number; + local_host?: string; + } + + export interface Tunnel { + url: string; + tunnel_cluster: TunnelCluster; + open(err: string, tunnel?: localtunnel.Tunnel): void; + close(): void; + } + + export interface TunnelCluster { + domain: string; + } + + const prototype: {}; +} + +export = localtunnel; diff --git a/types/localtunnel/localtunnel-tests.ts b/types/localtunnel/localtunnel-tests.ts new file mode 100644 index 0000000000..9d631c65e1 --- /dev/null +++ b/types/localtunnel/localtunnel-tests.ts @@ -0,0 +1,10 @@ +import localtunnel = require('localtunnel'); + +let tunnel: localtunnel.Tunnel; + +tunnel = localtunnel(3000, () => {}); +tunnel = localtunnel( + 3000, + { host: '', local_host: '', port: 3000, subdomain: '' }, + () => {} +); diff --git a/types/localtunnel/tsconfig.json b/types/localtunnel/tsconfig.json new file mode 100644 index 0000000000..d963a5e873 --- /dev/null +++ b/types/localtunnel/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "localtunnel-tests.ts" + ] +} diff --git a/types/localtunnel/tslint.json b/types/localtunnel/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/localtunnel/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 52bdd4690d4d6985dc762c7db8628d4d06844370 Mon Sep 17 00:00:00 2001 From: Vladyslav Khrapov Date: Mon, 8 Apr 2019 15:01:53 +0300 Subject: [PATCH 2/3] Fix test issues --- types/localtunnel/index.d.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/types/localtunnel/index.d.ts b/types/localtunnel/index.d.ts index 219075ed31..039aa1cf2c 100644 --- a/types/localtunnel/index.d.ts +++ b/types/localtunnel/index.d.ts @@ -1,12 +1,9 @@ -// Type definitions for localtunnel v1.9.1 -// Project: https://github.com/vladhrapov/typings +// Type definitions for localtunnel 1.0 +// Project: https://github.com/localtunnel/localtunnel // Definitions by: Vladyslav Khrapov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function localtunnel( - port: number, - callback: localtunnel.TunnelCallback -): localtunnel.Tunnel; +export = localtunnel; declare function localtunnel( port: number, @@ -14,31 +11,34 @@ declare function localtunnel( callback: localtunnel.TunnelCallback ): localtunnel.Tunnel; +declare function localtunnel( + port: number, + callback: localtunnel.TunnelCallback +): localtunnel.Tunnel; + declare namespace localtunnel { - export type TunnelCallback = ( + type TunnelCallback = ( err: string, - tunnel?: localtunnel.Tunnel + tunnel?: Tunnel ) => void; - export interface TunnelConfig { + interface TunnelConfig { host?: string; subdomain?: string; port?: number; local_host?: string; } - export interface Tunnel { + interface Tunnel { url: string; tunnel_cluster: TunnelCluster; - open(err: string, tunnel?: localtunnel.Tunnel): void; + open(err: string, tunnel?: Tunnel): void; close(): void; } - export interface TunnelCluster { + interface TunnelCluster { domain: string; } const prototype: {}; } - -export = localtunnel; From 15d7f39b7467de5f90df6eb0e685679847158265 Mon Sep 17 00:00:00 2001 From: Vladyslav Khrapov Date: Thu, 11 Apr 2019 22:48:53 +0300 Subject: [PATCH 3/3] Fix comments --- types/localtunnel/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/localtunnel/index.d.ts b/types/localtunnel/index.d.ts index 039aa1cf2c..38efd5862b 100644 --- a/types/localtunnel/index.d.ts +++ b/types/localtunnel/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for localtunnel 1.0 +// Type definitions for localtunnel 1.9 // Project: https://github.com/localtunnel/localtunnel // Definitions by: Vladyslav Khrapov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -39,6 +39,4 @@ declare namespace localtunnel { interface TunnelCluster { domain: string; } - - const prototype: {}; }