TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts
2015-11-06 14:25:32 -08:00

15 lines
232 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];
}
}