You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
5.6 regression: Inference with mixed in type intersection no longer compilesΒ #59765
typeFunctionComponent<P=any>=(props: P)=>Element|null;interfaceElementAttributes{idomKey?: string|null|number;children?: unknown;skip?: boolean;}declarefunctionelement<P>(tag: FunctionComponent<P&ElementAttributes>,attributes: P&ElementAttributes,): Element;declarefunctionElName(props: {name?: string}): Element;element(ElName,{});// Does not compile in 5.6. Should compile.
π Actual behavior
Last line errors with:
Argument of type '(props: { name?: string | undefined; }) => Element' is not assignable to parameter of type 'FunctionComponent<ElementAttributes>'.
Types of parameters 'props' and 'props' are incompatible.
Type 'ElementAttributes' has no properties in common with type '{ name?: string | undefined; }'.(2345)
π Expected behavior
Compiles as it did in previous versions
Additional information about the issue
Confirmed that #59709 does not resolve this issue.
changed the title [-]Inference with mixed in type intersection no longer compiles[/-][+]5.6 regression: Inference with mixed in type intersection no longer compiles[/+]on Aug 27, 2024
There are definitely going to be multiple correct possible inferences when all sites for a type parameter are the nested in the same intersection, and a "smaller" inference for P seems justifiable from the principle of being most likely to be sound in practice.
It seems like the "right" fix here is to change element to use a constraint instead:
Activity
RyanCavanaugh commentedon Aug 27, 2024
#57909 strikes once more cc Mateusz BurzyΕski (@Andarist)
Andarist commentedon Aug 27, 2024
This one is not beyond repair π #59772
[-]Inference with mixed in type intersection no longer compiles[/-][+]5.6 regression: Inference with mixed in type intersection no longer compiles[/+]RyanCavanaugh commentedon Aug 30, 2024
There are definitely going to be multiple correct possible inferences when all sites for a type parameter are the nested in the same intersection, and a "smaller" inference for
Pseems justifiable from the principle of being most likely to be sound in practice.It seems like the "right" fix here is to change
elementto use a constraint instead:which works as expected.
typescript-bot commentedon Sep 2, 2024
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.