From a1653d1bea63d267613fd8a1191e1c11b893e1b2 Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Tue, 8 Jan 2019 12:54:39 -0500 Subject: [PATCH 01/12] Add iopipe-js type declarations --- types/iopipe/index.d.ts | 22 ++++++++++++++++++++++ types/iopipe/iopipe-tests.ts | 17 +++++++++++++++++ types/iopipe/tsconfig.json | 22 ++++++++++++++++++++++ types/iopipe/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 types/iopipe/index.d.ts create mode 100644 types/iopipe/iopipe-tests.ts create mode 100644 types/iopipe/tsconfig.json create mode 100644 types/iopipe/tslint.json diff --git a/types/iopipe/index.d.ts b/types/iopipe/index.d.ts new file mode 100644 index 0000000000..046736956c --- /dev/null +++ b/types/iopipe/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for iopipe +// Project: https://github.com/iopipe/iopipe-js + +interface IOPipeConfig { + debug?: boolean; + token?: string; + networkTimeout?: number; + timeoutWindow?: number; +} + +interface Mark { + start(label: string): void; + end(label: string): void; +} + +declare module "@iopipe/iopipe" { + export function label(label: string): void; + export function metric(label: string, number: number): void; + export let mark: Mark + + export default function iopipe(config?: IOPipeConfig): Function; +} \ No newline at end of file diff --git a/types/iopipe/iopipe-tests.ts b/types/iopipe/iopipe-tests.ts new file mode 100644 index 0000000000..01fce909e4 --- /dev/null +++ b/types/iopipe/iopipe-tests.ts @@ -0,0 +1,17 @@ +import iopipe, { label, mark, metric } from '@iopipe/iopipe' + +const configuredLib = iopipe({ + token: 'ABCDEFG' +}); + +const run = () => {} + +configuredLib(run) + +label('a label'); + +mark.start('trace'); +mark.end('trace'); + +metric('metric-label', 42); + diff --git a/types/iopipe/tsconfig.json b/types/iopipe/tsconfig.json new file mode 100644 index 0000000000..ed43f65a14 --- /dev/null +++ b/types/iopipe/tsconfig.json @@ -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", + "iopipe-tests.ts" + ] +} diff --git a/types/iopipe/tslint.json b/types/iopipe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/iopipe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 39aec29f6a2da81b1a8483dfadb1ccb78690bdf7 Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Tue, 8 Jan 2019 13:09:49 -0500 Subject: [PATCH 02/12] Use 4 spaces --- types/iopipe/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/types/iopipe/index.d.ts b/types/iopipe/index.d.ts index 046736956c..965787a49a 100644 --- a/types/iopipe/index.d.ts +++ b/types/iopipe/index.d.ts @@ -2,21 +2,21 @@ // Project: https://github.com/iopipe/iopipe-js interface IOPipeConfig { - debug?: boolean; - token?: string; - networkTimeout?: number; - timeoutWindow?: number; + debug?: boolean; + token?: string; + networkTimeout?: number; + timeoutWindow?: number; } interface Mark { - start(label: string): void; - end(label: string): void; + start(label: string): void; + end(label: string): void; } declare module "@iopipe/iopipe" { - export function label(label: string): void; - export function metric(label: string, number: number): void; - export let mark: Mark + export function label(label: string): void; + export function metric(label: string, number: number): void; + export let mark: Mark - export default function iopipe(config?: IOPipeConfig): Function; + export default function iopipe(config?: IOPipeConfig): Function; } \ No newline at end of file From c2f0bc3b78080d945c920517ea425fcd4342daaa Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Tue, 8 Jan 2019 13:52:15 -0500 Subject: [PATCH 03/12] Clean up --- types/iopipe/iopipe-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/iopipe/iopipe-tests.ts b/types/iopipe/iopipe-tests.ts index 01fce909e4..4ebbf69f28 100644 --- a/types/iopipe/iopipe-tests.ts +++ b/types/iopipe/iopipe-tests.ts @@ -1,7 +1,7 @@ import iopipe, { label, mark, metric } from '@iopipe/iopipe' const configuredLib = iopipe({ - token: 'ABCDEFG' + token: 'ABCDEFG' }); const run = () => {} From c9d1d8aa3fcc6f224a29abf0a7c049ca703487ef Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Tue, 8 Jan 2019 18:21:50 -0500 Subject: [PATCH 04/12] Fix tests --- types/iopipe/index.d.ts | 45 ++++++++++++++++++++++++------------ types/iopipe/iopipe-tests.ts | 19 ++++++++------- types/iopipe/tsconfig.json | 1 + 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/types/iopipe/index.d.ts b/types/iopipe/index.d.ts index 965787a49a..be82b4125e 100644 --- a/types/iopipe/index.d.ts +++ b/types/iopipe/index.d.ts @@ -1,22 +1,37 @@ -// Type definitions for iopipe -// Project: https://github.com/iopipe/iopipe-js +// Type definitions for iopipe 1.6 +// Project: https://github.com/iopipe/the-meta-package#readme +// Definitions by: Javon Harper +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface IOPipeConfig { +interface LibraryConfig { debug?: boolean; token?: string; networkTimeout?: number; timeoutWindow?: number; } - -interface Mark { - start(label: string): void; - end(label: string): void; -} - + +type FunctionWrapper = (wrappedFunction: any) => void; + declare module "@iopipe/iopipe" { - export function label(label: string): void; - export function metric(label: string, number: number): void; - export let mark: Mark - - export default function iopipe(config?: IOPipeConfig): Function; -} \ No newline at end of file + namespace mark { + function start(label: string): void; + function end(label: string): void; + } + + function label(label: string): void; + function metric(label: string, number: number): void; + + export default function iopipe(config?: LibraryConfig): FunctionWrapper; +} + +declare module "@iopipe/core" { + namespace mark { + function start(label: string): void; + function end(label: string): void; + } + + function label(label: string): void; + function metric(label: string, number: number): void; + + export default function iopipe(config?: LibraryConfig): FunctionWrapper; +} diff --git a/types/iopipe/iopipe-tests.ts b/types/iopipe/iopipe-tests.ts index 4ebbf69f28..bffd85a763 100644 --- a/types/iopipe/iopipe-tests.ts +++ b/types/iopipe/iopipe-tests.ts @@ -1,17 +1,16 @@ -import iopipe, { label, mark, metric } from '@iopipe/iopipe' +import iopipe, { mark, label, metric } from "@iopipe/iopipe"; -const configuredLib = iopipe({ - token: 'ABCDEFG' +const configured = iopipe({ + token: "ABCDEFG" }); -const run = () => {} +const handler = () => {}; -configuredLib(run) +configured(handler); -label('a label'); +mark.start("api-call"); +mark.end("api-call"); -mark.start('trace'); -mark.end('trace'); - -metric('metric-label', 42); +label("here is a label"); +metric("magic number", 42); diff --git a/types/iopipe/tsconfig.json b/types/iopipe/tsconfig.json index ed43f65a14..e60c45b965 100644 --- a/types/iopipe/tsconfig.json +++ b/types/iopipe/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 1071812c8b5118a4189184f8f4a634824a051214 Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Wed, 16 Jan 2019 11:19:06 -0500 Subject: [PATCH 05/12] Remove iopipe, add iopipe__iopipe --- types/iopipe/index.d.ts | 37 ------------------ types/iopipe/iopipe-tests.ts | 16 -------- types/iopipe__iopipe/index.d.ts | 39 +++++++++++++++++++ types/iopipe__iopipe/iopipe__iopipe-tests.ts | 0 .../{iopipe => iopipe__iopipe}/tsconfig.json | 3 +- types/{iopipe => iopipe__iopipe}/tslint.json | 0 6 files changed, 40 insertions(+), 55 deletions(-) delete mode 100644 types/iopipe/index.d.ts delete mode 100644 types/iopipe/iopipe-tests.ts create mode 100644 types/iopipe__iopipe/index.d.ts create mode 100644 types/iopipe__iopipe/iopipe__iopipe-tests.ts rename types/{iopipe => iopipe__iopipe}/tsconfig.json (87%) rename types/{iopipe => iopipe__iopipe}/tslint.json (100%) diff --git a/types/iopipe/index.d.ts b/types/iopipe/index.d.ts deleted file mode 100644 index be82b4125e..0000000000 --- a/types/iopipe/index.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Type definitions for iopipe 1.6 -// Project: https://github.com/iopipe/the-meta-package#readme -// Definitions by: Javon Harper -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface LibraryConfig { - debug?: boolean; - token?: string; - networkTimeout?: number; - timeoutWindow?: number; -} - -type FunctionWrapper = (wrappedFunction: any) => void; - -declare module "@iopipe/iopipe" { - namespace mark { - function start(label: string): void; - function end(label: string): void; - } - - function label(label: string): void; - function metric(label: string, number: number): void; - - export default function iopipe(config?: LibraryConfig): FunctionWrapper; -} - -declare module "@iopipe/core" { - namespace mark { - function start(label: string): void; - function end(label: string): void; - } - - function label(label: string): void; - function metric(label: string, number: number): void; - - export default function iopipe(config?: LibraryConfig): FunctionWrapper; -} diff --git a/types/iopipe/iopipe-tests.ts b/types/iopipe/iopipe-tests.ts deleted file mode 100644 index bffd85a763..0000000000 --- a/types/iopipe/iopipe-tests.ts +++ /dev/null @@ -1,16 +0,0 @@ -import iopipe, { mark, label, metric } from "@iopipe/iopipe"; - -const configured = iopipe({ - token: "ABCDEFG" -}); - -const handler = () => {}; - -configured(handler); - -mark.start("api-call"); -mark.end("api-call"); - -label("here is a label"); - -metric("magic number", 42); diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts new file mode 100644 index 0000000000..6ac9b10a4d --- /dev/null +++ b/types/iopipe__iopipe/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for iopipe__iopipe x.x +// Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ If this module is a UMD module that exposes a global variable 'myLib' when + *~ loaded outside a module loader environment, declare that global here. + *~ Otherwise, delete this declaration. + */ +export as namespace myLib; + +/*~ If this module has methods, declare them as functions like so. + */ +export function myMethod(a: string): string; +export function myOtherMethod(a: number): number; + +/*~ You can declare types that are available via importing the module */ +export interface someType { + name: string; + length: number; + extras?: string[]; +} + +/*~ You can declare properties of the module using const, let, or var */ +export const myField: number; + +/*~ If there are types, properties, or methods inside dotted names + *~ of the module, declare them inside a 'namespace'. + */ +export namespace subProp { + /*~ For example, given this definition, someone could write: + *~ import { subProp } from 'yourModule'; + *~ subProp.foo(); + *~ or + *~ import * as yourMod from 'yourModule'; + *~ yourMod.subProp.foo(); + */ + export function foo(): void; +} \ No newline at end of file diff --git a/types/iopipe__iopipe/iopipe__iopipe-tests.ts b/types/iopipe__iopipe/iopipe__iopipe-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json similarity index 87% rename from types/iopipe/tsconfig.json rename to types/iopipe__iopipe/tsconfig.json index e60c45b965..65de67cc3a 100644 --- a/types/iopipe/tsconfig.json +++ b/types/iopipe__iopipe/tsconfig.json @@ -7,7 +7,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -18,6 +17,6 @@ }, "files": [ "index.d.ts", - "iopipe-tests.ts" + "iopipe__iopipe-tests.ts" ] } diff --git a/types/iopipe/tslint.json b/types/iopipe__iopipe/tslint.json similarity index 100% rename from types/iopipe/tslint.json rename to types/iopipe__iopipe/tslint.json From c7c0bed850ce81ba8a5e3af855a6b82f58e31a9b Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Wed, 16 Jan 2019 11:28:01 -0500 Subject: [PATCH 06/12] Fix tests --- types/iopipe__iopipe/index.d.ts | 8 +++++--- types/iopipe__iopipe/iopipe__iopipe-tests.ts | 3 +++ types/iopipe__iopipe/tsconfig.json | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts index 6ac9b10a4d..77955ed6b8 100644 --- a/types/iopipe__iopipe/index.d.ts +++ b/types/iopipe__iopipe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for iopipe__iopipe x.x +// Type definitions for iopipe__iopipe 1.12 // Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) // Definitions by: My Self // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -35,5 +35,7 @@ export namespace subProp { *~ import * as yourMod from 'yourModule'; *~ yourMod.subProp.foo(); */ - export function foo(): void; -} \ No newline at end of file + function foo(): void; +} + +export function label(value: string): void; diff --git a/types/iopipe__iopipe/iopipe__iopipe-tests.ts b/types/iopipe__iopipe/iopipe__iopipe-tests.ts index e69de29bb2..9860d4c563 100644 --- a/types/iopipe__iopipe/iopipe__iopipe-tests.ts +++ b/types/iopipe__iopipe/iopipe__iopipe-tests.ts @@ -0,0 +1,3 @@ +import { label } from "iopipe__iopipe"; + +label('this is a label'); diff --git a/types/iopipe__iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json index 65de67cc3a..01d23ff29d 100644 --- a/types/iopipe__iopipe/tsconfig.json +++ b/types/iopipe__iopipe/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -18,5 +19,8 @@ "files": [ "index.d.ts", "iopipe__iopipe-tests.ts" - ] + ], + "paths": { + "@iopipe/iopipe": ["iopipe__iopipe"] + } } From 27fbd374d8c021578bde56a6a86e1acad69330dd Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Wed, 16 Jan 2019 13:44:04 -0500 Subject: [PATCH 07/12] Clean up definitions --- types/iopipe__iopipe/index.d.ts | 49 +++++++------------- types/iopipe__iopipe/iopipe__iopipe-tests.ts | 18 ++++++- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts index 77955ed6b8..591501c5aa 100644 --- a/types/iopipe__iopipe/index.d.ts +++ b/types/iopipe__iopipe/index.d.ts @@ -1,41 +1,24 @@ // Type definitions for iopipe__iopipe 1.12 -// Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) -// Definitions by: My Self +// Project: https://github.com/iopipe/iopipe (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Javon Harper // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/*~ If this module is a UMD module that exposes a global variable 'myLib' when - *~ loaded outside a module loader environment, declare that global here. - *~ Otherwise, delete this declaration. - */ -export as namespace myLib; - -/*~ If this module has methods, declare them as functions like so. - */ -export function myMethod(a: string): string; -export function myOtherMethod(a: number): number; - -/*~ You can declare types that are available via importing the module */ -export interface someType { - name: string; - length: number; - extras?: string[]; +export interface LibraryConfig { + debug?: boolean; + token?: string; + networkTimeout?: number; + timeoutWindow?: number; } -/*~ You can declare properties of the module using const, let, or var */ -export const myField: number; +export type FunctionWrapper = (handler: any) => void; -/*~ If there are types, properties, or methods inside dotted names - *~ of the module, declare them inside a 'namespace'. - */ -export namespace subProp { - /*~ For example, given this definition, someone could write: - *~ import { subProp } from 'yourModule'; - *~ subProp.foo(); - *~ or - *~ import * as yourMod from 'yourModule'; - *~ yourMod.subProp.foo(); - */ - function foo(): void; +export function label(label: string): void; + +export function metric(label: string, value: number): void; + +export namespace mark { + function start(label: string): void; + function end(label: string): void; } -export function label(value: string): void; +export default function iopipe(config?: LibraryConfig): FunctionWrapper; diff --git a/types/iopipe__iopipe/iopipe__iopipe-tests.ts b/types/iopipe__iopipe/iopipe__iopipe-tests.ts index 9860d4c563..a48dfe7416 100644 --- a/types/iopipe__iopipe/iopipe__iopipe-tests.ts +++ b/types/iopipe__iopipe/iopipe__iopipe-tests.ts @@ -1,3 +1,17 @@ -import { label } from "iopipe__iopipe"; +import iopipe, { label, metric, mark, LibraryConfig } from "iopipe__iopipe"; -label('this is a label'); +const config: LibraryConfig = { + token: "ABCDEFG" +}; + +function run(event: any, context: any, callback?: any) { + label('my label'); + + metric("magic number", 42); + + mark.start("my-db-call"); + // an expensive database query + mark.end("my-db-call"); +} + +iopipe(config)(run); From 8375a616cb319c8bab9b98e027336d19cb979ddc Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Wed, 16 Jan 2019 14:04:08 -0500 Subject: [PATCH 08/12] Use es module interop --- types/iopipe__iopipe/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/iopipe__iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json index 01d23ff29d..f0770af65c 100644 --- a/types/iopipe__iopipe/tsconfig.json +++ b/types/iopipe__iopipe/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, + "esModuleInterop": true, "baseUrl": "../", "typeRoots": [ "../" From c62fd2660967a254eb506e358f91046e5c02b8a8 Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Wed, 16 Jan 2019 14:43:07 -0500 Subject: [PATCH 09/12] Use export = syntax --- types/iopipe__iopipe/index.d.ts | 20 ++++++++++++-------- types/iopipe__iopipe/iopipe__iopipe-tests.ts | 4 ++-- types/iopipe__iopipe/tsconfig.json | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts index 591501c5aa..42a68f7015 100644 --- a/types/iopipe__iopipe/index.d.ts +++ b/types/iopipe__iopipe/index.d.ts @@ -3,22 +3,26 @@ // Definitions by: Javon Harper // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export interface LibraryConfig { +interface LibraryConfig { debug?: boolean; token?: string; networkTimeout?: number; timeoutWindow?: number; } -export type FunctionWrapper = (handler: any) => void; +type FunctionWrapper = (handler: any) => void; -export function label(label: string): void; +declare function iopipe(config?: LibraryConfig): FunctionWrapper; -export function metric(label: string, value: number): void; +declare namespace iopipe { + function label(label: string): void; -export namespace mark { - function start(label: string): void; - function end(label: string): void; + function metric(label: string, value: number): void; + + namespace mark { + function start(label: string): void; + function end(label: string): void; + } } -export default function iopipe(config?: LibraryConfig): FunctionWrapper; +export = iopipe; diff --git a/types/iopipe__iopipe/iopipe__iopipe-tests.ts b/types/iopipe__iopipe/iopipe__iopipe-tests.ts index a48dfe7416..8f5b9bae29 100644 --- a/types/iopipe__iopipe/iopipe__iopipe-tests.ts +++ b/types/iopipe__iopipe/iopipe__iopipe-tests.ts @@ -1,6 +1,6 @@ -import iopipe, { label, metric, mark, LibraryConfig } from "iopipe__iopipe"; +import iopipe, { label, metric, mark } from "iopipe__iopipe"; -const config: LibraryConfig = { +const config = { token: "ABCDEFG" }; diff --git a/types/iopipe__iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json index f0770af65c..eaab1ac3c6 100644 --- a/types/iopipe__iopipe/tsconfig.json +++ b/types/iopipe__iopipe/tsconfig.json @@ -8,7 +8,7 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "esModuleInterop": true, + "allowSyntheticDefaultImports": true, "baseUrl": "../", "typeRoots": [ "../" From 94f578a44a3ccbe430f98aef428251d29546e59c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Jan 2019 11:47:23 -0800 Subject: [PATCH 10/12] Update tsconfig.json --- types/iopipe__iopipe/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/iopipe__iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json index eaab1ac3c6..f0770af65c 100644 --- a/types/iopipe__iopipe/tsconfig.json +++ b/types/iopipe__iopipe/tsconfig.json @@ -8,7 +8,7 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "allowSyntheticDefaultImports": true, + "esModuleInterop": true, "baseUrl": "../", "typeRoots": [ "../" From a538358862e0f4f0187a44a6227d6d092f5afe50 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Jan 2019 12:45:48 -0800 Subject: [PATCH 11/12] Move implicit exports into the namespace. --- types/iopipe__iopipe/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts index 42a68f7015..cd53ebcfa8 100644 --- a/types/iopipe__iopipe/index.d.ts +++ b/types/iopipe__iopipe/index.d.ts @@ -3,16 +3,7 @@ // Definitions by: Javon Harper // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface LibraryConfig { - debug?: boolean; - token?: string; - networkTimeout?: number; - timeoutWindow?: number; -} - -type FunctionWrapper = (handler: any) => void; - -declare function iopipe(config?: LibraryConfig): FunctionWrapper; +declare function iopipe(config?: iopipe.LibraryConfig): iopipe.FunctionWrapper; declare namespace iopipe { function label(label: string): void; @@ -23,6 +14,15 @@ declare namespace iopipe { function start(label: string): void; function end(label: string): void; } + + interface LibraryConfig { + debug?: boolean; + token?: string; + networkTimeout?: number; + timeoutWindow?: number; + } + + type FunctionWrapper = (handler: any) => void; } export = iopipe; From 2e9f4758aa3bf4a56b23040ea82910c5f472c042 Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Wed, 16 Jan 2019 16:38:59 -0500 Subject: [PATCH 12/12] Fix tests, can't do named + default import --- types/iopipe__iopipe/index.d.ts | 2 +- types/iopipe__iopipe/iopipe__iopipe-tests.ts | 10 +++++----- types/iopipe__iopipe/tsconfig.json | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts index cd53ebcfa8..338de9ca58 100644 --- a/types/iopipe__iopipe/index.d.ts +++ b/types/iopipe__iopipe/index.d.ts @@ -14,7 +14,7 @@ declare namespace iopipe { function start(label: string): void; function end(label: string): void; } - + interface LibraryConfig { debug?: boolean; token?: string; diff --git a/types/iopipe__iopipe/iopipe__iopipe-tests.ts b/types/iopipe__iopipe/iopipe__iopipe-tests.ts index 8f5b9bae29..f5bd387dc8 100644 --- a/types/iopipe__iopipe/iopipe__iopipe-tests.ts +++ b/types/iopipe__iopipe/iopipe__iopipe-tests.ts @@ -1,17 +1,17 @@ -import iopipe, { label, metric, mark } from "iopipe__iopipe"; +import iopipe = require('iopipe__iopipe'); const config = { token: "ABCDEFG" }; function run(event: any, context: any, callback?: any) { - label('my label'); + iopipe.label('my label'); - metric("magic number", 42); + iopipe.metric("magic number", 42); - mark.start("my-db-call"); + iopipe.mark.start("my-db-call"); // an expensive database query - mark.end("my-db-call"); + iopipe.mark.end("my-db-call"); } iopipe(config)(run); diff --git a/types/iopipe__iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json index f0770af65c..01d23ff29d 100644 --- a/types/iopipe__iopipe/tsconfig.json +++ b/types/iopipe__iopipe/tsconfig.json @@ -8,7 +8,6 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "esModuleInterop": true, "baseUrl": "../", "typeRoots": [ "../"