Skip to content

spread of overloaded function rejected on generic components in JSX as of 4.7.4 #51577

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

Closed
eps1lon opened this issue Nov 17, 2022 · 1 comment Β· Fixed by #51580 or #53444
Closed

spread of overloaded function rejected on generic components in JSX as of 4.7.4 #51577

eps1lon opened this issue Nov 17, 2022 · 1 comment Β· Fixed by #51580 or #53444
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@eps1lon
Copy link
Contributor

eps1lon commented Nov 17, 2022

Bug Report

πŸ”Ž Search Terms

spread jsx generic overload

πŸ•— Version & Regression Information

  • This changed between versions 4.6.4 and 4.7.4

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

function GenericComponent<T>(props: { foo?: string }) {
    return null
}
function GenericComponent<T>(props: { foo?: string }) {
    return null
}
<GenericComponent {...omit(['foo'], otherProps)} />;

πŸ™ Actual behavior

Spread types may only be created from object types.(2698)
unless we save omit(['foo'], otherProps) in an intermediate variable and spread that instead (work around in playground).

πŸ™‚ Expected behavior

No error since it's valid at runtime. It's also accepted by TS without JSX or on non-generic components or if we save the value in an intermediate variable. All cases are explored in the playground.

@jakebailey
Copy link
Member

jakebailey commented Mar 16, 2023

#51580 and #52837 didn't play along, so the fix for this has been reverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment