Skip to content

[code-infra] Allow more permissive Element types#48186

Merged
JCQuintas merged 3 commits intomui:masterfrom
JCQuintas:fix-jsx.element-gen
May 6, 2026
Merged

[code-infra] Allow more permissive Element types#48186
JCQuintas merged 3 commits intomui:masterfrom
JCQuintas:fix-jsx.element-gen

Conversation

@JCQuintas
Copy link
Copy Markdown
Member

@JCQuintas JCQuintas commented Apr 2, 2026

There are some instances in X where the resolver uses the file location as the import name, which means we need to manually say that function returns a component.

// something like
const MyComponent = (): React.JSX.Element => <div />

Else it resolves to ".../node_modules/@types/react/jsx-runtime".JSX.Element

In this PR I make the resolver more permissive by only checking that the final types have the correct name.

@JCQuintas JCQuintas self-assigned this Apr 2, 2026
@JCQuintas JCQuintas added type: bug It doesn't behave as expected. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). labels Apr 2, 2026
@mui-bot
Copy link
Copy Markdown

mui-bot commented Apr 2, 2026

Netlify deploy preview

https://deploy-preview-48186--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 68d1480

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 21, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 30, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented Apr 30, 2026

Deploy preview

https://deploy-preview-48186--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@JCQuintas JCQuintas marked this pull request as ready for review April 30, 2026 13:07
@JCQuintas JCQuintas requested a review from a team April 30, 2026 13:08
@Janpot
Copy link
Copy Markdown
Member

Janpot commented May 6, 2026

Why is it resolving to ".../node_modules/@types/react/jsx-runtime".JSX.Element? I feel like that could be an indicator something else is wrong in the types. Do you have a specific reproduction?

Copy link
Copy Markdown
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Ok, nvm, did some testing

// A — no return-type annotation
export default function Component(props: Props) {
  return <div>{props.value}</div>;
}

// B — explicit annotation
export default function Component(props: Props): React.JSX.Element {
  return <div>{props.value}</div>;
}

checker.getFullyQualifiedName(returnType.symbol) output:

A: "/.../node_modules/.pnpm/@types+react@19.2.14/node_modules/@types/react/jsx-runtime".JSX.Element

B: React.JSX.Element

This PR is probably the best we can do atm

@JCQuintas JCQuintas merged commit bbcd5ea into mui:master May 6, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants