TypeScript Version: 2.7.0-dev.201xxxxx
We do not perform mutability widening on jsx attributes as we do for object property assignments. Since we do not do the same kind of inference on jsx (and do not have generic jsx return types), this is difficult to witness (since the literal is compatible with its constraint), but is potentially a big performance hit for JSX users that was hidden. The example below is one case where the difference can be witnessed:
Code
function Bar<TSame>(props: {x: TSame, y: TSame}) {
return <span />
}
<Bar x="a" y="b" />
Bar({
x: "a",
y: "b"
})
Expected behavior:
Bar's quickinfo shows Bar<string> on both styles of call - TSame is not constrained to string or another literal domain, so its use sites should not be literal locations.
Actual behavior:
Bar's quickinfo shows Bar<"a" | "b"> for the JSX call, but Bar<string> for the normal call.
TypeScript Version: 2.7.0-dev.201xxxxx
We do not perform mutability widening on jsx attributes as we do for object property assignments. Since we do not do the same kind of inference on jsx (and do not have generic jsx return types), this is difficult to witness (since the literal is compatible with its constraint), but is potentially a big performance hit for JSX users that was hidden. The example below is one case where the difference can be witnessed:
Code
Expected behavior:
Bar's quickinfo shows
Bar<string>on both styles of call - TSame is not constrained tostringor another literal domain, so its use sites should not be literal locations.Actual behavior:
Bar's quickinfo shows
Bar<"a" | "b">for the JSX call, butBar<string>for the normal call.