diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index f6e5bd81fe46e1..21d49c019bc1dc 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -36,15 +36,15 @@ export interface Options { /** * Babel configuration applied in both dev and prod. */ - babel?: Pick + babel?: BabelOptions /** * @deprecated Use `babel.parserOpts.plugins` instead */ parserPlugins?: ParserOptions['plugins'] } -type SupportedBabelOptions = Exclude< - keyof TransformOptions, +export type BabelOptions = Omit< + TransformOptions, | 'ast' | 'filename' | 'root' @@ -53,11 +53,18 @@ type SupportedBabelOptions = Exclude< | 'inputSourceMap' > -type ReactBabelOptions = { - [P in SupportedBabelOptions]: Exclude & - (P extends 'parserOpts' - ? { plugins: Exclude } - : unknown) +/** + * The object type used by the `options` passed to plugins with + * an `api.reactBabel` method. + */ +export interface ReactBabelOptions + extends Omit, + Required> { + plugins: Extract + presets: Extract + parserOpts: ParserOptions & { + plugins: Extract + } } declare module 'vite' {