-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'vitest-dev:main' into fix/rerun-setup-files
- Loading branch information
Showing
78 changed files
with
3,770 additions
and
2,859 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# assertType | ||
|
||
- **Type:** `<T>(value: T): void` | ||
|
||
You can use this function as an alternative for [`expectTypeOf`](/api/expect-typeof) to easily assert that the argument type is equal to the generic provided. | ||
|
||
```ts | ||
import { assertType } from 'vitest' | ||
|
||
function concat(a: string, b: string): string | ||
function concat(a: number, b: number): number | ||
function concat(a: string | number, b: string | number): string | number | ||
|
||
assertType<string>(concat('a', 'b')) | ||
assertType<number>(concat(1, 2)) | ||
// @ts-expect-error wrong types | ||
assertType(concat('a', 2)) | ||
``` |
Oops, something went wrong.