@@ -4,14 +4,26 @@ const list = [1, 2, 3]
44
55describe ( 'R.filter with array' , ( ) => {
66 it ( 'within pipe' , ( ) => {
7- const _result = pipe (
7+ const result = pipe (
88 list ,
99 filter ( x => {
1010 x // $ExpectType number
1111 return x > 1
1212 } ) ,
1313 )
14- _result // $ExpectType number[]
14+ result // $ExpectType number[]
15+ } )
16+
17+ it ( 'with index' , ( ) => {
18+ const result = pipe (
19+ list ,
20+ filter ( ( x : number , i : number ) => {
21+ x // $ExpectType number
22+ i // $ExpectType number
23+ return x > 1
24+ } ) ,
25+ )
26+ result // $ExpectType number[]
1527 } )
1628
1729 it ( 'complex example' , ( ) => {
@@ -50,8 +62,8 @@ describe('R.filter with array', () => {
5062 const filterBar = ( x : T ) : x is Bar => {
5163 return typeof ( x as Bar ) . b === 'string'
5264 }
53- const _result = pipe ( testList , filter ( filterBar ) )
54- _result // $ExpectType Bar[]
65+ const result = pipe ( testList , filter ( filterBar ) )
66+ result // $ExpectType Bar[]
5567 } )
5668
5769 it ( 'narrowing type - readonly' , ( ) => {
@@ -66,14 +78,14 @@ describe('R.filter with array', () => {
6678 const filterBar = ( x : T ) : x is Bar => {
6779 return typeof ( x as Bar ) . b === 'string'
6880 }
69- const _result = pipe ( testList , filter ( filterBar ) )
70- _result // $ExpectType Bar[]
81+ const result = pipe ( testList , filter ( filterBar ) )
82+ result // $ExpectType Bar[]
7183 } )
7284
7385 it ( 'filtering NonNullable - list of objects' , ( ) => {
7486 const testList = [ { a : 1 } , { a : 2 } , false , { a : 3 } ]
75- const _result = pipe ( testList , filter ( Boolean ) )
76- _result // $ExpectType { a: number; }[]
87+ const result = pipe ( testList , filter ( Boolean ) )
88+ result // $ExpectType { a: number; }[]
7789 } )
7890
7991 it ( 'filtering NonNullable - readonly' , ( ) => {
0 commit comments