From 88962b29f4266036153e6be445a035a12513aa65 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sun, 6 Aug 2017 00:44:12 +0200 Subject: [PATCH] [p-props] introduce typings --- types/p-props/index.d.ts | 10 ++++++++++ types/p-props/p-props-tests.ts | 21 +++++++++++++++++++++ types/p-props/tsconfig.json | 22 ++++++++++++++++++++++ types/p-props/tslint.json | 1 + 4 files changed, 54 insertions(+) create mode 100644 types/p-props/index.d.ts create mode 100644 types/p-props/p-props-tests.ts create mode 100644 types/p-props/tsconfig.json create mode 100644 types/p-props/tslint.json diff --git a/types/p-props/index.d.ts b/types/p-props/index.d.ts new file mode 100644 index 0000000000..38ee03b990 --- /dev/null +++ b/types/p-props/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for p-props 1.0 +// Project: https://github.com/sindresorhus/p-props#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export = pProps; + +declare function pProps | V }>(input: M): Promise>; +declare function pProps(input: Map | V>): Promise>; diff --git a/types/p-props/p-props-tests.ts b/types/p-props/p-props-tests.ts new file mode 100644 index 0000000000..651d613193 --- /dev/null +++ b/types/p-props/p-props-tests.ts @@ -0,0 +1,21 @@ +import pProps = require('p-props'); +import got = require('got'); + +const fetch = (url: string): Promise => got(url).then(res => res.body); + +const sites = { + ava: fetch('ava.li'), + todomvc: fetch('todomvc.com'), + github: fetch('github.com'), + foo: 'bar' +}; + +pProps(sites).then(result => { + const str: string = result.github; +}); + +const map = new Map>([[1, Promise.resolve('1')], [2, '2']]); + +pProps(map).then(result => { + const str: string | undefined = result.get(1); +}); diff --git a/types/p-props/tsconfig.json b/types/p-props/tsconfig.json new file mode 100644 index 0000000000..7e5309c521 --- /dev/null +++ b/types/p-props/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", + "p-props-tests.ts" + ] +} diff --git a/types/p-props/tslint.json b/types/p-props/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/p-props/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }