Skip to content

Commit

Permalink
fix: typescript error in production build
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jan 4, 2022
1 parent 97ad93b commit 53399ab
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export interface Options {
/**
* Babel configuration applied in both dev and prod.
*/
babel?: Pick<TransformOptions, SupportedBabelOptions>
babel?: BabelOptions
/**
* @deprecated Use `babel.parserOpts.plugins` instead
*/
parserPlugins?: ParserOptions['plugins']
}

type SupportedBabelOptions = Exclude<
keyof TransformOptions,
export type BabelOptions = Omit<
TransformOptions,
| 'ast'
| 'filename'
| 'root'
Expand All @@ -53,11 +53,16 @@ type SupportedBabelOptions = Exclude<
| 'inputSourceMap'
>

type ReactBabelOptions = {
[P in SupportedBabelOptions]: Exclude<TransformOptions[P], null | undefined> &
(P extends 'parserOpts'
? { plugins: Exclude<ParserOptions['plugins'], undefined> }
: unknown)
/**
* The object type used by the `options` passed to plugins with
* an `api.reactBabel` method.
*/
export interface ReactBabelOptions extends BabelOptions {
plugins: Extract<BabelOptions['plugins'], any[]>
presets: Extract<BabelOptions['presets'], any[]>
parserOpts: ParserOptions & {
plugins: Extract<ParserOptions['plugins'], any[]>
}
}

declare module 'vite' {
Expand Down

0 comments on commit 53399ab

Please sign in to comment.