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
feat(types): add generic type for plugin api #5112
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #5112 +/- ##
=======================================
Coverage 98.96% 98.96%
=======================================
Files 226 226
Lines 8394 8394
Branches 2303 2303
=======================================
Hits 8307 8307
Misses 31 31
Partials 56 56 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
This PR has been released as part of rollup@3.29.0. You can test it via |
declare module 'vite' {
export interface Plugin {
api?: {
/**
* Manipulate the Babel options of `@vitejs/plugin-react`
*/
reactBabel?: ReactBabelHook
}
}
} But this now fails with this generic types:
I changed to try to directly overload the rollup types with: declare module 'rollup' {
export interface Plugin<A = any> {
api?: {
/**
* Manipulate the Babel options of `@vitejs/plugin-react`
*/
reactBabel?: ReactBabelHook
}
}
} but I now get:
Does anyone knows how I can get the same behavior as before with this new type? Is there any expected way to type this? |
The react plugin itself should solve it. Please track issue vitejs/vite-plugin-react#258 |
Yeah but I don't know how to solve it |
@ArnaudBarre What about using types like interface ViteReactPluginApi {
/**
* Manipulate the Babel options of `@vitejs/plugin-react`
*/
reactBabel?: ReactBabelHook;
}
type ViteReactPlugin = Plugin<ViteReactPluginApi>; instead of |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
Add a generic type for Plugin.api