mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[p-forever] Add types
This commit is contained in:
19
types/p-forever/index.d.ts
vendored
Normal file
19
types/p-forever/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for p-forever 1.0
|
||||
// Project: https://github.com/sindresorhus/p-forever#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
export = pForever;
|
||||
|
||||
declare function pForever<T>(
|
||||
fn: (previousValue?: T) => T | PromiseLike<T> | typeof pForever.end
|
||||
): Promise<void>;
|
||||
declare function pForever<T>(
|
||||
fn: (previousValue: T) => T | PromiseLike<T> | typeof pForever.end,
|
||||
initialValue: T
|
||||
): Promise<void>;
|
||||
|
||||
declare namespace pForever {
|
||||
const end: unique symbol;
|
||||
}
|
||||
33
types/p-forever/p-forever-tests.ts
Normal file
33
types/p-forever/p-forever-tests.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import pForever = require('p-forever');
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
pForever(i => {
|
||||
// $ExpectType number
|
||||
i;
|
||||
i++;
|
||||
return i <= 100 ? i : pForever.end;
|
||||
}, 0);
|
||||
// $ExpectType Promise<void>
|
||||
pForever(i => {
|
||||
// $ExpectType number
|
||||
i;
|
||||
i++;
|
||||
return i <= 100 ? Promise.resolve(i) : pForever.end;
|
||||
}, 0);
|
||||
|
||||
let i = 0;
|
||||
|
||||
// $ExpectType Promise<void>
|
||||
pForever<number>(prevI => {
|
||||
// $ExpectType number | undefined
|
||||
prevI;
|
||||
i++;
|
||||
return i <= 100 ? i : pForever.end;
|
||||
});
|
||||
// $ExpectType Promise<void>
|
||||
pForever<number>(prevI => {
|
||||
// $ExpectType number | undefined
|
||||
prevI;
|
||||
i++;
|
||||
return i <= 100 ? Promise.resolve(i) : pForever.end;
|
||||
});
|
||||
23
types/p-forever/tsconfig.json
Normal file
23
types/p-forever/tsconfig.json
Normal file
@@ -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-forever-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/p-forever/tslint.json
Normal file
1
types/p-forever/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user