@@ -2,12 +2,14 @@ import {expectType} from 'tsd';
2
2
import pPipe = require( '.' ) ;
3
3
4
4
const fn = async ( string : string ) => `${ string } Unicorn` ;
5
+ const noInput = async ( ) => 'called without input' ;
5
6
6
7
const identity = < T > ( value : T ) => value ;
7
8
const toNumber = ( string : string ) => parseInt ( string ) ;
8
9
const toFixed = ( number : number ) => number . toFixed ( 2 ) ;
9
10
10
11
expectType < Promise < string > > ( pPipe ( fn ) ( '❤️' ) ) ;
12
+ expectType < Promise < string > > ( pPipe ( noInput ) ( ) ) ;
11
13
expectType < Promise < string > > ( pPipe ( toNumber , toFixed ) ( '❤️' ) ) ;
12
14
13
15
expectType < Promise < string > > ( pPipe ( fn , identity , identity ) ( '❤️' ) ) ;
@@ -47,6 +49,14 @@ expectType<Promise<string>>(
47
49
) ( '❤️' )
48
50
) ;
49
51
52
+ expectType < Promise < string > > (
53
+ pPipe (
54
+ noInput ,
55
+ identity ,
56
+ identity
57
+ ) ( )
58
+ ) ;
59
+
50
60
expectType < unknown > (
51
61
pPipe (
52
62
fn ,
@@ -61,12 +71,20 @@ expectType<unknown>(
61
71
identity
62
72
) ( '❤️' )
63
73
) ;
74
+ expectType < unknown > (
75
+ pPipe (
76
+ noInput ,
77
+ identity ,
78
+ identity
79
+ ) ( )
80
+ ) ;
64
81
65
82
// "Complex" examples
66
83
const byPowerOfTwo = ( number : number ) => number ** 2 ;
67
84
const asResult = async < T > ( result : T ) => ( { result} ) ;
68
85
const either = async ( number : number ) => ( number > 2 ? number : '🤪' ) ;
69
86
const count = ( number : number ) => [ ...Array ( number ) . keys ( ) ] ;
87
+ const fetchNumber = async ( ) => 2 ;
70
88
71
89
expectType < Promise < { result : string } > > (
72
90
pPipe ( byPowerOfTwo , toFixed , asResult ) ( 2 )
@@ -75,3 +93,6 @@ expectType<Promise<{result: number | string}>>(
75
93
pPipe ( byPowerOfTwo , either , asResult ) ( 2 )
76
94
) ;
77
95
expectType < Promise < number [ ] > > ( pPipe ( byPowerOfTwo , count ) ( 2 ) ) ;
96
+ expectType < Promise < { result : number | string } > > (
97
+ pPipe ( fetchNumber , either , asResult ) ( )
98
+ ) ;
0 commit comments