Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: internal coverage typings #2713

Merged

Conversation

AriPerkkio
Copy link
Member

Fixes multiple internal typing violations of coverage typings. Reduces the amount of as type assertions used to trick tsc. Typings are now actually correct and respond the runtime values.

  • Tested intellisense manually on locally linked project
  • test/coverage-test/test/configuration-options.test-d.ts is passing

Comment on lines -56 to -59
export type CoverageOptions =
| BaseCoverageOptions & { provider?: null | CoverageProviderModule }
| CoverageC8Options & { provider?: 'c8' }
| CoverageIstanbulOptions & { provider?: 'istanbul' }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to refactor this union type into a conditional type due to weird behaviour in TypeScript. Link to TS Playground

It seems that Typescript thinks a string may also extend the interface CoverageProviderModule.

type NarrowedProvider = "istanbul" | ({ method: () => string; } & "istanbul")

@sheremet-va sheremet-va merged commit 1503e15 into vitest-dev:main Jan 21, 2023
@AriPerkkio AriPerkkio deleted the refactor/internal-coverage-typings branch January 21, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants