Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rikuayanokozy/master
add typescript definitions
- Loading branch information
Showing
5 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type Tuple<T1, T2> = [T1, T2]; | ||
type A2AResult<TResult, TError> = Tuple<TError|null, TResult|undefined>; | ||
|
||
declare function a2a<TResult=any, TError = any>(promise: Promise<TResult>): Promise<A2AResult<TResult, TError>>; | ||
declare function a2a<TResult=any, TError = any>(promise: Promise<TResult>[]): Promise<A2AResult<TResult[], TError>>; | ||
|
||
export default a2a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import a2a from '../'; | ||
|
||
a2a(Promise.resolve(1)) | ||
.then(([err, result]) => { | ||
console.log(result as number); | ||
}); | ||
|
||
a2a([Promise.resolve(1)]) | ||
.then(([err, result]) => { | ||
console.log(result as number[]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "commonjs", | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"types": ["node"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["index.d.ts", "test/*.ts"] | ||
} |