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

16 lines
No EOL
234 B
TypeScript

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