Description
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.