23
23
*
24
24
* @returns result
25
25
*/
26
- type Nullary = ( ) => any ;
26
+ type Nullary < T > = ( this : T ) => any ;
27
27
28
28
/**
29
29
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
30
30
*
31
31
* @param value - grapheme cluster
32
32
* @returns result
33
33
*/
34
- type Unary = ( value : string ) => any ;
34
+ type Unary < T > = ( this : T , value : string ) => any ;
35
35
36
36
/**
37
37
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -40,7 +40,7 @@ type Unary = ( value: string ) => any;
40
40
* @param index - starting grapheme cluster index
41
41
* @returns result
42
42
*/
43
- type Binary = ( value : string , index : number ) => any ;
43
+ type Binary < T > = ( this : T , value : string , index : number ) => any ;
44
44
45
45
/**
46
46
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -50,7 +50,7 @@ type Binary = ( value: string, index: number ) => any;
50
50
* @param str - input string
51
51
* @returns result
52
52
*/
53
- type Ternary = ( value : string , index : number , str : string ) => any ;
53
+ type Ternary < T > = ( this : T , value : string , index : number , str : string ) => any ;
54
54
55
55
/**
56
56
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -60,7 +60,7 @@ type Ternary = ( value: string, index: number, str: string ) => any;
60
60
* @param str - input string
61
61
* @returns result
62
62
*/
63
- type Callback = Nullary | Unary | Binary | Ternary ;
63
+ type Callback < T > = Nullary < T > | Unary < T > | Binary < T > | Ternary < T > ;
64
64
65
65
/**
66
66
* Invokes a function for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -85,7 +85,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
85
85
*
86
86
* forEach( 'Hello, World!', log );
87
87
*/
88
- declare function forEach ( str : string , clbk : Callback , thisArg ?: any ) : string ;
88
+ declare function forEach < T = unknown > ( str : string , clbk : Callback < T > , thisArg ?: ThisParameterType < Callback < T > > ) : string ;
89
89
90
90
91
91
// EXPORTS //
0 commit comments