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.
|
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 |
|
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
Clear and concise description of the problem
Now that
v8andistanbulproviders support same same identical options, there is no need for complexcoverage.providerspecific typings.vitest/packages/vitest/src/node/types/coverage.ts
Lines 98 to 111 in f87817d
vitest/packages/vitest/src/node/types/coverage.ts
Lines 290 to 298 in f87817d
It also seems that currently when
vitest.config.tsis included intsconfig.json'sinclude, thecoverage.providerbecomes required field. Not sure why. It should default tov8but it doesn't work anymore 🤷♂️Instead of fixing this complex type, let's just simplify the types overall.
Suggested solution
interface CoverageOptionsshould just beBaseCoverageOptions. 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.tsis included intsconfig.json:Additional context
No response
Validations