Skip to content

string is not assignable to string union for TSX component props #6231

Closed
@basarat

Description

@basarat

Sample code :

type Foo = "f"|"o";
const FooComp = (props:{foo:Foo}) => <span>{props.foo}</span>;
<FooComp foo={"f"}/>; // Okay
<FooComp foo="f"/>; // Error : Type string is not assignable to "f"|"o";  Should be allowed and type checked 🌹

PS: can we get a JSX / TSX label. Would help me to search 🌹

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitterDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions