Skip to content

Commit d97df70

Browse files
committed
feat!: fix parameter order and ensure type safety of this context
1 parent 5c70f69 commit d97df70

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

lib/node_modules/@stdlib/utils/while/docs/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
// TypeScript Version: 2.0
19+
// TypeScript Version: 4.1
2020

2121
/**
2222
* Checks whether an iteration number passes a test.
@@ -51,7 +51,7 @@ type Predicate = ( i: number ) => boolean;
5151
*
5252
* whilst( predicate, beep );
5353
*/
54-
declare function whilst( fcn: Function, predicate: Predicate, thisArg?: any ): void; // tslint:disable-line: max-line-length
54+
declare function whilst<T extends Function>( predicate: Predicate, fcn: T, thisArg?: ThisParameterType<T> ): void; // tslint:disable-line: max-line-length
5555

5656

5757
// EXPORTS //

lib/node_modules/@stdlib/utils/while/docs/types/test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,32 @@ function noop() {
4040

4141
// The function does not return a value...
4242
{
43-
whilst( noop, predicate ); // $ExpectType void
44-
whilst( noop, predicate, {} ); // $ExpectType void
43+
whilst( predicate, noop ); // $ExpectType void
44+
whilst( predicate, noop, {} ); // $ExpectType void
4545
}
4646

4747
// The compiler throws an error if the function is provided a first argument which is not a function...
4848
{
49-
whilst( 'abc', predicate ); // $ExpectError
50-
whilst( 5, predicate ); // $ExpectError
51-
whilst( true, predicate ); // $ExpectError
52-
whilst( false, predicate ); // $ExpectError
53-
whilst( [], predicate ); // $ExpectError
54-
whilst( {}, predicate ); // $ExpectError
49+
whilst( 'abc', noop ); // $ExpectError
50+
whilst( 5, noop ); // $ExpectError
51+
whilst( true, noop ); // $ExpectError
52+
whilst( false, noop ); // $ExpectError
53+
whilst( [], noop ); // $ExpectError
54+
whilst( {}, noop ); // $ExpectError
5555
}
5656

5757
// The compiler throws an error if the function is provided a second argument which is not a function...
5858
{
59-
whilst( noop, 'abc' ); // $ExpectError
60-
whilst( noop, 5 ); // $ExpectError
61-
whilst( noop, true ); // $ExpectError
62-
whilst( noop, false ); // $ExpectError
63-
whilst( noop, [] ); // $ExpectError
64-
whilst( noop, {} ); // $ExpectError
59+
whilst( predicate, 'abc' ); // $ExpectError
60+
whilst( predicate, 5 ); // $ExpectError
61+
whilst( predicate, true ); // $ExpectError
62+
whilst( predicate, false ); // $ExpectError
63+
whilst( predicate, [] ); // $ExpectError
64+
whilst( predicate, {} ); // $ExpectError
6565
}
6666

6767
// The compiler throws an error if the function is provided fewer than two arguments...
6868
{
6969
whilst(); // $ExpectError
70-
whilst( noop ); // $ExpectError
70+
whilst( predicate ); // $ExpectError
7171
}

0 commit comments

Comments
 (0)