-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Clear and concise description of the problem
Now that v8 and istanbul providers support same same identical options, there is no need for complex coverage.provider specific typings.
vitest/packages/vitest/src/node/types/coverage.ts
Lines 98 to 111 in f87817d
| export type CoverageOptions<T extends CoverageProviderName = CoverageProviderName> | |
| = T extends 'istanbul' | |
| ? { provider: T } & CoverageIstanbulOptions | |
| : T extends 'v8' ? { | |
| /** | |
| * Provider to use for coverage collection. | |
| * | |
| * @default 'v8' | |
| */ | |
| provider: T | |
| } & CoverageV8Options | |
| : T extends 'custom' | |
| ? { provider: T } & CustomProviderOptions | |
| : { provider?: T } & CoverageV8Options |
vitest/packages/vitest/src/node/types/coverage.ts
Lines 290 to 298 in f87817d
| export interface CoverageIstanbulOptions extends BaseCoverageOptions {} | |
| export interface CoverageV8Options extends BaseCoverageOptions {} | |
| export interface CustomProviderOptions | |
| extends Pick<BaseCoverageOptions, FieldsWithDefaultValues | 'changed'> { | |
| /** Name of the module or path to a file to load the custom provider from */ | |
| customProviderModule: string | |
| } |
It also seems that currently when vitest.config.ts is included in tsconfig.json's include, the coverage.provider becomes required field. Not sure why. It should default to v8 but it doesn't work anymore 🤷♂️
Instead of fixing this complex type, let's just simplify the types overall.
Suggested solution
interface CoverageOptions should just be BaseCoverageOptions. If some option is provider specific (currently none), it should be stated in JSDocs.
Alternative
Fix current complex types so that following would not cause type errors when vitest.config.ts is included in tsconfig.json:
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
include: ["src/**/*.{ts,tsx}"],
},
},
}); Property 'provider' is missing in type '{ include: string[]; }' but required in type '{ provider: "v8"; }'.ts(2769)
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.