1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts ===
type Kind = "A" | "B"
>Kind : Symbol(Kind, Decl(stringLiteralTypesTypePredicates01.ts, 0, 0))
function kindIs(kind: Kind, is: "A"): kind is "A";
>kindIs : Symbol(kindIs, Decl(stringLiteralTypesTypePredicates01.ts, 1, 21), Decl(stringLiteralTypesTypePredicates01.ts, 3, 50), Decl(stringLiteralTypesTypePredicates01.ts, 4, 50))
>kind : Symbol(kind, Decl(stringLiteralTypesTypePredicates01.ts, 3, 16))
>Kind : Symbol(Kind, Decl(stringLiteralTypesTypePredicates01.ts, 0, 0))
>is : Symbol(is, Decl(stringLiteralTypesTypePredicates01.ts, 3, 27))
>kind : Symbol(kind, Decl(stringLiteralTypesTypePredicates01.ts, 3, 16))
function kindIs(kind: Kind, is: "B"): kind is "B";
>kindIs : Symbol(kindIs, Decl(stringLiteralTypesTypePredicates01.ts, 1, 21), Decl(stringLiteralTypesTypePredicates01.ts, 3, 50), Decl(stringLiteralTypesTypePredicates01.ts, 4, 50))
>kind : Symbol(kind, Decl(stringLiteralTypesTypePredicates01.ts, 4, 16))
>Kind : Symbol(Kind, Decl(stringLiteralTypesTypePredicates01.ts, 0, 0))
>is : Symbol(is, Decl(stringLiteralTypesTypePredicates01.ts, 4, 27))
>kind : Symbol(kind, Decl(stringLiteralTypesTypePredicates01.ts, 4, 16))
function kindIs(kind: Kind, is: Kind): boolean {
>kindIs : Symbol(kindIs, Decl(stringLiteralTypesTypePredicates01.ts, 1, 21), Decl(stringLiteralTypesTypePredicates01.ts, 3, 50), Decl(stringLiteralTypesTypePredicates01.ts, 4, 50))
>kind : Symbol(kind, Decl(stringLiteralTypesTypePredicates01.ts, 5, 16))
>Kind : Symbol(Kind, Decl(stringLiteralTypesTypePredicates01.ts, 0, 0))
>is : Symbol(is, Decl(stringLiteralTypesTypePredicates01.ts, 5, 27))
>Kind : Symbol(Kind, Decl(stringLiteralTypesTypePredicates01.ts, 0, 0))
return kind === is;
>kind : Symbol(kind, Decl(stringLiteralTypesTypePredicates01.ts, 5, 16))
>is : Symbol(is, Decl(stringLiteralTypesTypePredicates01.ts, 5, 27))
}
var x: Kind = undefined;
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
>Kind : Symbol(Kind, Decl(stringLiteralTypesTypePredicates01.ts, 0, 0))
>undefined : Symbol(undefined)
if (kindIs(x, "A")) {
>kindIs : Symbol(kindIs, Decl(stringLiteralTypesTypePredicates01.ts, 1, 21), Decl(stringLiteralTypesTypePredicates01.ts, 3, 50), Decl(stringLiteralTypesTypePredicates01.ts, 4, 50))
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
let a = x;
>a : Symbol(a, Decl(stringLiteralTypesTypePredicates01.ts, 12, 7))
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
}
else {
let b = x;
>b : Symbol(b, Decl(stringLiteralTypesTypePredicates01.ts, 15, 7))
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
}
if (!kindIs(x, "B")) {
>kindIs : Symbol(kindIs, Decl(stringLiteralTypesTypePredicates01.ts, 1, 21), Decl(stringLiteralTypesTypePredicates01.ts, 3, 50), Decl(stringLiteralTypesTypePredicates01.ts, 4, 50))
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
let c = x;
>c : Symbol(c, Decl(stringLiteralTypesTypePredicates01.ts, 19, 7))
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
}
else {
let d = x;
>d : Symbol(d, Decl(stringLiteralTypesTypePredicates01.ts, 22, 7))
>x : Symbol(x, Decl(stringLiteralTypesTypePredicates01.ts, 9, 3))
}
|