-
-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop tsd for tests in favor of expect-type
`tsd` is a somewhat heavy-weight dependency that is unnecessary considering that `expect-type` is already a depdency of `type-fest`.
- Loading branch information
Showing
80 changed files
with
813 additions
and
799 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
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import {expectType, expectError} from 'tsd'; | ||
import {expectTypeOf} from 'expect-type'; | ||
import type {Asyncify} from '../index'; | ||
|
||
declare function getFooSync(name: string): RegExp; | ||
declare function getFooWithThisArgSync(this: Date, name: string): RegExp; | ||
|
||
// Basic usage. | ||
declare const getFooAsync1: Asyncify<typeof getFooSync>; | ||
expectType<(name: string) => Promise<RegExp>>(getFooAsync1); | ||
expectTypeOf(getFooAsync1).toEqualTypeOf<(name: string) => Promise<RegExp>>(); | ||
|
||
// Noops with async functions. | ||
declare const getFooAsync2: Asyncify<typeof getFooAsync1>; | ||
expectType<typeof getFooAsync1>(getFooAsync2); | ||
expectTypeOf(getFooAsync2).toEqualTypeOf<typeof getFooAsync1>(); | ||
|
||
// Respects `thisArg`. | ||
declare const getFooWithThisArgAsync1: Asyncify<typeof getFooWithThisArgSync>; | ||
const callResult = getFooWithThisArgAsync1.call(new Date(), 'foo'); | ||
expectType<Promise<RegExp>>(callResult); | ||
expectError(getFooWithThisArgAsync1.call('not-date', 'foo')); | ||
expectTypeOf(callResult).toEqualTypeOf<Promise<RegExp>>(); | ||
// @ts-expect-error | ||
void getFooWithThisArgAsync1.call('not-date', 'foo'); |
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
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
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
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
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
Oops, something went wrong.