Skip to content
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

JSX Attributes should be considered mutable locations #20705

Closed
weswigham opened this issue Dec 14, 2017 · 0 comments
Closed

JSX Attributes should be considered mutable locations #20705

weswigham opened this issue Dec 14, 2017 · 0 comments
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Fixed A PR has been merged for this issue

Comments

@weswigham
Copy link
Member

weswigham commented Dec 14, 2017

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.

@weswigham weswigham added Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter labels Dec 14, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Jan 11, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 11, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants