Merge pull request #18668 from BendingBender/p-props

[p-props] introduce typings
This commit is contained in:
Daniel Rosenwasser
2017-08-15 11:41:16 -07:00
committed by GitHub
4 changed files with 54 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for p-props 1.0
// Project: https://github.com/sindresorhus/p-props#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = pProps;
declare function pProps<V, M extends { [key: string]: PromiseLike<V> | V }>(input: M): Promise<Record<keyof M, V>>;
declare function pProps<K, V>(input: Map<K, PromiseLike<V> | V>): Promise<Map<K, V>>;
+21
View File
@@ -0,0 +1,21 @@
import pProps = require('p-props');
import got = require('got');
const fetch = (url: string): Promise<string> => got(url).then(res => res.body);
const sites = {
ava: fetch('ava.li'),
todomvc: fetch('todomvc.com'),
github: fetch('github.com'),
foo: 'bar'
};
pProps<string, typeof sites>(sites).then(result => {
const str: string = result.github;
});
const map = new Map<number, string | Promise<string>>([[1, Promise.resolve('1')], [2, '2']]);
pProps(map).then(result => {
const str: string | undefined = result.get(1);
});
+22
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",
"p-props-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }