From a1653d1bea63d267613fd8a1191e1c11b893e1b2 Mon Sep 17 00:00:00 2001 From: Javon Harper Date: Tue, 8 Jan 2019 12:54:39 -0500 Subject: [PATCH] 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" }