Closed
Description
TypeScript Version: 2.1.5
There is a conditional operator literal string type problem, ts cannot resolve true ? "a" : "b"
as a type, which may call some errors.
for example:
type a_or_b = "a" | "b" ;
let v1 = (true ? "a" : "b");
let v2: a_or_b;
v2 = v1; // ERROR
Expected behavior:
expect no error.
Actual behavior:
but it comes up with an error as follow:
TS2322
I know a solution to refrain this error is changing the line 2 to be let v1: any = (true ? "a" : "b");
or let v1: a_or_b = (true ? "a" : "b");
, but this procedure seem to should be needless.