-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Domain: 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
TypeScript Version: 2.0.0-dev.20160702
Code
const t = (a: "a"|"b") => a;
const b = "a";
t(b);
Expected behavior:
No errors
Actual behavior:
src/index.tsx(3,3): error TS2345: Argument of type 'string' is not assignable to parameter of type '"a" | "b"'.
This is just a toy example, and can be fixed with enums or other approaches.
I'm actually having this issue, where tsc gives me a lot of error in the CSS.
For example
src/index.tsx(33,13): error TS2322: Type '{ flex: number; justifyContent: string; alignItems: string; backgroundColor: string; }' is not assignable to type 'ViewStyle'.
Types of property 'alignItems' are incompatible.
Type 'string' is not assignable to type '"flex-start" | "flex-end" | "center" | "stretch"'.
Please also note that
t("a");
doesn't give any error, but I can't really use it to solve the react issue.
I'm not sure if there is another issue related to the same problem. I tried to search in the opened issues but I haven't found anything.
pindexis and 75lb
Metadata
Metadata
Assignees
Labels
Domain: 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