From 53399ab748f5eebd2debc628ea1763a02650847a Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Tue, 4 Jan 2022 14:20:39 -0500 Subject: [PATCH] fix: typescript error in production build --- packages/plugin-react/src/index.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index f6e5bd81fe46e1..aa6ae8197ff036 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,16 @@ 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 BabelOptions { + plugins: Extract + presets: Extract + parserOpts: ParserOptions & { + plugins: Extract + } } declare module 'vite' {