Skip to content

Commit

Permalink
docs: split API into separate pages (#2635)
Browse files Browse the repository at this point in the history
* docs: split API into separate pages

* Apply suggestions from code review

Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com>

Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com>
  • Loading branch information
sheremet-va and dammy001 committed Jan 16, 2023
1 parent 0a31e85 commit 8b50123
Show file tree
Hide file tree
Showing 8 changed files with 2,791 additions and 2,734 deletions.
22 changes: 21 additions & 1 deletion docs/.vitepress/config.ts
Expand Up @@ -181,9 +181,29 @@ export default defineConfig({
text: 'API',
items: [
{
text: 'API Reference',
text: 'Test API Reference',
link: '/api/',
},
{
text: 'Mock Functions',
link: '/api/mock',
},
{
text: 'Vi Utility',
link: '/api/vi',
},
{
text: 'Expect',
link: '/api/expect',
},
{
text: 'ExpectTypeOf',
link: '/api/expect-typeof',
},
{
text: 'assertType',
link: '/api/assert-type',
},
],
},
{
Expand Down
18 changes: 18 additions & 0 deletions docs/api/assert-type.md
@@ -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))
```

0 comments on commit 8b50123

Please sign in to comment.