swc/crates/swc_ecma_parser/tests/tsc/stringLiteralCheckedInIf01.ts

15 lines
218 B
TypeScript

type S = "a" | "b";
type T = S[] | S;
function f(foo: T) {
if (foo === "a") {
return foo;
}
else if (foo === "b") {
return foo;
}
else {
return (foo as S[])[0];
}
}