mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
[p-tap] introduce typings (#18711)
This commit is contained in:
committed by
Mohamed Hegazy
parent
48e27a5c81
commit
3c43f5038a
13
types/p-tap/index.d.ts
vendored
Normal file
13
types/p-tap/index.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Type definitions for p-tap 1.0
|
||||
// Project: https://github.com/sindresorhus/p-tap#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = pTap;
|
||||
|
||||
declare const pTap: pTap;
|
||||
|
||||
interface pTap {
|
||||
<T>(fn: (value: T) => any): (value: T) => Promise<T>;
|
||||
catch(fn: (value: any) => any): (value: any) => Promise<never>;
|
||||
}
|
||||
26
types/p-tap/p-tap-tests.ts
Normal file
26
types/p-tap/p-tap-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import pTap = require('p-tap');
|
||||
|
||||
Promise.resolve('unicorn')
|
||||
.then(pTap<string>(val => {
|
||||
let str: string = val;
|
||||
return 1;
|
||||
}))
|
||||
.then(val => {
|
||||
let str: string = val;
|
||||
});
|
||||
|
||||
Promise.resolve('unicorn')
|
||||
.then(pTap<string>(val => {
|
||||
let str: string = val;
|
||||
return Promise.resolve(1);
|
||||
}))
|
||||
.then(val => {
|
||||
let str: string = val;
|
||||
});
|
||||
|
||||
Promise.reject(new Error())
|
||||
.catch(pTap.catch(val => {
|
||||
const num: number = val;
|
||||
}))
|
||||
.then(() => 1)
|
||||
.catch(() => {});
|
||||
22
types/p-tap/tsconfig.json
Normal file
22
types/p-tap/tsconfig.json
Normal 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-tap-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/p-tap/tslint.json
Normal file
1
types/p-tap/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user