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

Typescript: Provide types for Babel and Vite istanbul options #10

Merged
merged 10 commits into from
Nov 21, 2022

Conversation

bryanjtc
Copy link
Member

The interface InstanbulOptions now extends InstabulPluginOptions from the vite plugin instanbul.
This makes available more types when using this plugin in the storybook config with typescript.

@bryanjtc
Copy link
Member Author

@yannbf Can you check this? It's a small change, so I don't think there isn't any problem.

Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

Hey @bryanjtc thanks a lot for your contribution! This has a side effect though.
This addon is available for both Babel-based projects and Vite-based projects. Therefore, the types are now wrong for Babel projects, given that vite-plugin-istanbul has options that do not exist in babel-plugin-istanbul.

If you'd like this change I'd suggest to:

  • Create two separate types and export them as AddonOptionsBabel and AddonOptionsVite
  • Update the documentation in README and add the options supported by Vite in a way that is clear that it's for Vite projects only

@bryanjtc bryanjtc requested a review from yannbf November 16, 2022 14:24
@bryanjtc
Copy link
Member Author

@yannbf I did what you asked and also modified istanbul from addonoptions so that it can be an union type. It can either have the options for the babel plugin or the vite plugin.

@yannbf
Copy link
Member

yannbf commented Nov 21, 2022

Hey @bryanjtc this is great! thank you so much for following up. I took the liberty to work on top of things, as the type union wouldn't work as well unless we introduced a Discriminated Union, which wouldn't make a lot of sense for js projects. So I simplified things and we just have two exports: AddonOptionsBabel and AddonOptionsVite.

@yannbf yannbf changed the title fix: Add types from vite plugin instanbul Typescript: Provide types for Babel and Vite istanbul options Nov 21, 2022
@yannbf yannbf added the patch Increment the patch version when merged label Nov 21, 2022
@yannbf yannbf merged commit 1c3d8da into storybookjs:main Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants