Skip to content

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

@eps1lon

Description

@eps1lon

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.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions