mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #18668 from BendingBender/p-props
[p-props] introduce typings
This commit is contained in:
Vendored
+10
@@ -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>>;
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user