Skip to content

fix: Accept partial plugin options #12

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danreeves
Copy link

@danreeves danreeves commented Jun 9, 2025

Resolves #9

Currently the PluginOptions exported by babel-plugin-react-compiler expects most keys to be populated but in reality the babel plugin accepts partial objects, so it would be better if defineReactCompilerLoaderOption accepted Partial<PluginOptions>.

defineReactCompilerLoaderOption({ target: '17' }) is valid but the types won't accept it.

Screenshot 2025-06-09 at 16 30 27

As a workaround, users can just set options: { target: '17' }, but then you lose typing.

Copy link
Owner

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

Ideally, we really should be aligned with the upstream types.

Let's say, if the React Compiler has updated options, that if you have A configured, you must also specify B, or you should not specify them at all:

XOR<{}, { A: unknown, B: unknown }>

Now with partial we can't do type safe anymore.

@SukkaW
Copy link
Owner

SukkaW commented Jun 13, 2025

Maybe the PR should be opened to the upstream instead. IIRC they are using zod, so this should be very easy to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to integrate react-compiler-webpack with webpack config when ts is used
2 participants