mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for p-time 1.0
|
||||
// Project: https://github.com/sindresorhus/p-time#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
export = pTime;
|
||||
|
||||
declare function pTime<TArgs extends any[], TRes>(
|
||||
fn: (...args: TArgs) => PromiseLike<TRes>
|
||||
): (...args: TArgs) => pTime.PromiseWithTime<TRes>;
|
||||
|
||||
declare namespace pTime {
|
||||
const log: typeof pTime;
|
||||
|
||||
interface PromiseWithTime<T> extends Promise<T> {
|
||||
time?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import pTime = require('p-time');
|
||||
|
||||
const wrappedFn = pTime(async (input: number) => {
|
||||
return input;
|
||||
});
|
||||
|
||||
// $ExpectType (input: number) => PromiseWithTime<number>
|
||||
wrappedFn;
|
||||
|
||||
// $ExpectType number | undefined
|
||||
wrappedFn(1).time;
|
||||
|
||||
// $ExpectError
|
||||
pTime((input: number) => {
|
||||
return input;
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
wrappedFn('foo');
|
||||
|
||||
// $ExpectType (input: number) => PromiseWithTime<number>
|
||||
pTime.log(async (input: number) => {
|
||||
return input;
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"p-time-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user