Skip to content
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

Improve transform-react-jsx typings #13820

Merged
merged 7 commits into from Oct 7, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Oct 6, 2021

Q                       A
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR starts by improving typings of transform-react-jsx, the type checker catches unreachable statements in

for (const attr of path.get("attributes")) {
if (!attr.isJSXElement()) continue;
const { name } = attr.node.name;
if (name === "__source" || name === "__self") {
throw path.buildCodeFrameError(
`__source and __self should not be defined in props and are reserved for internal usage.`,
);
}

The guard should have been !attr.isJSXAttribute(). However, since we have already thrown selfSourceError in automatic runtime

if (found[name]) throw sourceSelfError(path, name);

and we allow multiple __self and __source in classical runtime. I think current behavior is ok so we can simply remove the unreachable statements.

This PR also exports a PluginPass type from @babel/core, which can be used by plugin authors.

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories PR: Internal 🏠 A type of pull request used for our changelog categories labels Oct 6, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Oct 6, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/49085/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 6, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c487241:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@JLHwung JLHwung marked this pull request as draft October 6, 2021 13:34
@JLHwung JLHwung force-pushed the improve-transform-react-jsx-typings branch from db5f158 to cca951b Compare October 6, 2021 13:41
@JLHwung JLHwung removed the PR: Spec Compliance 👓 A type of pull request used for our changelog categories label Oct 6, 2021
@JLHwung JLHwung marked this pull request as ready for review October 6, 2021 19:47
packages/babel-core/src/index.ts Outdated Show resolved Hide resolved
@JLHwung JLHwung merged commit c2f747c into babel:main Oct 7, 2021
@JLHwung JLHwung deleted the improve-transform-react-jsx-typings branch October 7, 2021 18:01
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants