-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueDomain: JSX/TSXRelates to the JSX parser and emitterRelates to the JSX parser and emitterDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
The original issue is issue #10171. Currently we don't treat property assignment of JSX element as literal type as issue #10171 illustrates
type TextProps = { editable: false }
| { editable: true, onEdit: (newText: string) => void }
class TextComponent extends React.Component<TextProps, {}> {
render() {
return <span>Some Text..</span>;
}
}
ReactDOM.render(
<TextComponent editable={true} />, // editable is of type boolean not of type "true"
document.getElementById("example")
);One possible solution is to treat property as literal type instead. This could possibly affect how overload will work as well
normalser
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueDomain: JSX/TSXRelates to the JSX parser and emitterRelates to the JSX parser and emitterDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript