Skip to content

Commit

Permalink
Merge branch 'main' into fix/4425
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuibu authored Nov 23, 2023
2 parents 51482d5 + 16033e0 commit 8babbe2
Show file tree
Hide file tree
Showing 17 changed files with 594 additions and 633 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ jobs:
with:
node-version: ${{ matrix.node_version }}

- uses: browser-actions/setup-chrome@v1

- name: Install
run: pnpm i

- name: Install Playwright Dependencies
run: pnpx playwright install --with-deps

- name: Build
run: pnpm run build

Expand Down
28 changes: 16 additions & 12 deletions docs/api/assert-type.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# assertType

- **Type:** `<T>(value: T): void`
::: warning
During runtime this function doesn't do anything. To [enable typechecking](/guide/testing-types#run-typechecking), don't forget to pass down `--typecheck` flag.
:::

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.
- **Type:** `<T>(value: T): void`

```ts
import { assertType } from 'vitest'
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.

function concat(a: string, b: string): string
function concat(a: number, b: number): number
function concat(a: string | number, b: string | number): string | number
```ts
import { assertType } from 'vitest'

assertType<string>(concat('a', 'b'))
assertType<number>(concat(1, 2))
// @ts-expect-error wrong types
assertType(concat('a', 2))
```
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))
```
Loading

0 comments on commit 8babbe2

Please sign in to comment.