https://github.com/xc2/vitest-types
Zero dependencies TypeScript declarations package for vitest 2 and 3.
https://github.com/xc2/vitest-types
typescript-definitions vitest
Last synced: 4 months ago
JSON representation
Zero dependencies TypeScript declarations package for vitest 2 and 3.
- Host: GitHub
- URL: https://github.com/xc2/vitest-types
- Owner: xc2
- Created: 2024-12-20T18:12:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-19T13:37:33.000Z (over 1 year ago)
- Last Synced: 2026-01-24T11:41:54.890Z (5 months ago)
- Topics: typescript-definitions, vitest
- Language: TypeScript
- Homepage: https://npm.im/vitest-types
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vitest-types
This package allows you to use `import { expect, test, ... } from "vitest"` statements in your ts test files without needing to add `vitest` to your `dependencies` or `devDependencies` lists.
Supported versions:
- vitest 2.x
- vitest 3.x
> [!NOTE]
> Vitest Node APIs are not included in this package. You will still need to install `vitest` to use them. For example:
>
> - `vitest/node`
> - `vitest/config`
## Installation
```sh
pnpm/yarn/npm add --save-dev vitest-types
```
### vitest 2.x
Then add `vitest-types/2` to `compilerOptions.types` list in the `tsconfig.json`. For example:
```json
{
"compilerOptions": {
"types": ["vitest-types/2"]
}
}
```
### vitest 3.x
Then add `vitest-types/3` to `compilerOptions.types` list in the `tsconfig.json`. For example:
```json
{
"compilerOptions": {
"types": ["vitest-types/3"]
}
}
```
Now you can use `import { expect, test, ... } from "vitest"` in your test files.
```ts
// a.test.ts
import { expect, test } from "vitest";
test('foo', () => {
expect(1).toBe(1);
})
```
## APIs Global Injection
When you're running vitest with apis global injection(`--globals`), you should also add `vitest-types/2/globals`/`vitest-types/3/globals` to the `compilerOptions.types` list. For example:
```json
{
"compilerOptions": {
"types": ["vitest-types/2/globals"]
}
}
```
```ts
// a.test.ts
test('foo', () => {
expect(1).toBe(1);
})
```
## License
[MIT ©️ xc2](https://tldr.ws/mitxc2)