Open danvk opened 5 years ago
Here are a few variations that do work:
function test(t: 'foo' | 'bar') {
t; // $ExpectType "foo" | "bar"
}
let t: 'foo' | 'bar';
t; // $ExpectType "foo" | "bar"
So I guess you just can't do a type assertion on the line in which a variable is declared? It has to be on an expression?
If I add this to
expectType.ts.lint
:and run
npm run build && npm run test
, then I get the following error:Somehow the type union gets converted to "any". Putting that same code in the TypeScript playground shows that TS understands the type correctly. I'm not sure what's going on here.