TypeScript/tests/baselines/reference/typeGuardFunction.symbols
2015-06-24 10:48:22 +08:00

215 lines
7.5 KiB
Plaintext

=== tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts ===
class A {
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
propA: number;
>propA : Symbol(propA, Decl(typeGuardFunction.ts, 1, 9))
}
class B {
>B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1))
propB: number;
>propB : Symbol(propB, Decl(typeGuardFunction.ts, 5, 9))
}
class C extends A {
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
propC: number;
>propC : Symbol(propC, Decl(typeGuardFunction.ts, 9, 19))
}
declare function isA(p1: any): p1 is A;
>isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 13, 21))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 13, 21))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
declare function isB(p1: any): p1 is B;
>isB : Symbol(isB, Decl(typeGuardFunction.ts, 13, 39))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 14, 21))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 14, 21))
>B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1))
declare function isC(p1: any): p1 is C;
>isC : Symbol(isC, Decl(typeGuardFunction.ts, 14, 39))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 15, 21))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 15, 21))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
declare function retC(): C;
>retC : Symbol(retC, Decl(typeGuardFunction.ts, 15, 39))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
var a: A;
>a : Symbol(a, Decl(typeGuardFunction.ts, 19, 3))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
var b: B;
>b : Symbol(b, Decl(typeGuardFunction.ts, 20, 3))
>B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1))
// Basic
if (isC(a)) {
>isC : Symbol(isC, Decl(typeGuardFunction.ts, 14, 39))
>a : Symbol(a, Decl(typeGuardFunction.ts, 19, 3))
a.propC;
>a.propC : Symbol(C.propC, Decl(typeGuardFunction.ts, 9, 19))
>a : Symbol(a, Decl(typeGuardFunction.ts, 19, 3))
>propC : Symbol(C.propC, Decl(typeGuardFunction.ts, 9, 19))
}
// Sub type
var subType: C;
>subType : Symbol(subType, Decl(typeGuardFunction.ts, 28, 3))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
if(isA(subType)) {
>isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1))
>subType : Symbol(subType, Decl(typeGuardFunction.ts, 28, 3))
subType.propC;
>subType.propC : Symbol(C.propC, Decl(typeGuardFunction.ts, 9, 19))
>subType : Symbol(subType, Decl(typeGuardFunction.ts, 28, 3))
>propC : Symbol(C.propC, Decl(typeGuardFunction.ts, 9, 19))
}
// Union type
var union: A | B;
>union : Symbol(union, Decl(typeGuardFunction.ts, 34, 3))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1))
if(isA(union)) {
>isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1))
>union : Symbol(union, Decl(typeGuardFunction.ts, 34, 3))
union.propA;
>union.propA : Symbol(A.propA, Decl(typeGuardFunction.ts, 1, 9))
>union : Symbol(union, Decl(typeGuardFunction.ts, 34, 3))
>propA : Symbol(A.propA, Decl(typeGuardFunction.ts, 1, 9))
}
// Call signature
interface I1 {
>I1 : Symbol(I1, Decl(typeGuardFunction.ts, 37, 1))
(p1: A): p1 is C;
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 41, 5))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 41, 5))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
}
// The parameter index and argument index for the type guard target is matching.
// The type predicate type is assignable to the parameter type.
declare function isC_multipleParams(p1, p2): p1 is C;
>isC_multipleParams : Symbol(isC_multipleParams, Decl(typeGuardFunction.ts, 42, 1))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 46, 36))
>p2 : Symbol(p2, Decl(typeGuardFunction.ts, 46, 39))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 46, 36))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
if (isC_multipleParams(a, 0)) {
>isC_multipleParams : Symbol(isC_multipleParams, Decl(typeGuardFunction.ts, 42, 1))
>a : Symbol(a, Decl(typeGuardFunction.ts, 19, 3))
a.propC;
>a.propC : Symbol(C.propC, Decl(typeGuardFunction.ts, 9, 19))
>a : Symbol(a, Decl(typeGuardFunction.ts, 19, 3))
>propC : Symbol(C.propC, Decl(typeGuardFunction.ts, 9, 19))
}
// Methods
var obj: {
>obj : Symbol(obj, Decl(typeGuardFunction.ts, 52, 3))
func1(p1: A): p1 is C;
>func1 : Symbol(func1, Decl(typeGuardFunction.ts, 52, 10))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 53, 10))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 53, 10))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
}
class D {
>D : Symbol(D, Decl(typeGuardFunction.ts, 54, 1))
method1(p1: A): p1 is C {
>method1 : Symbol(method1, Decl(typeGuardFunction.ts, 55, 9))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 56, 12))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 56, 12))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
return true;
}
}
// Arrow function
let f1 = (p1: A): p1 is C => false;
>f1 : Symbol(f1, Decl(typeGuardFunction.ts, 62, 3))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 62, 10))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 62, 10))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
// Function type
declare function f2(p1: (p1: A) => p1 is C);
>f2 : Symbol(f2, Decl(typeGuardFunction.ts, 62, 35))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 65, 20))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 65, 25))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 65, 25))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
// Function expressions
f2(function(p1: A): p1 is C {
>f2 : Symbol(f2, Decl(typeGuardFunction.ts, 62, 35))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 68, 12))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 68, 12))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
return true;
});
// Evaluations are asssignable to boolean.
declare function acceptingBoolean(a: boolean);
>acceptingBoolean : Symbol(acceptingBoolean, Decl(typeGuardFunction.ts, 70, 3))
>a : Symbol(a, Decl(typeGuardFunction.ts, 73, 34))
acceptingBoolean(isA(a));
>acceptingBoolean : Symbol(acceptingBoolean, Decl(typeGuardFunction.ts, 70, 3))
>isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1))
>a : Symbol(a, Decl(typeGuardFunction.ts, 19, 3))
// Type predicates with different parameter name.
declare function acceptingTypeGuardFunction(p1: (item) => item is A);
>acceptingTypeGuardFunction : Symbol(acceptingTypeGuardFunction, Decl(typeGuardFunction.ts, 74, 25))
>p1 : Symbol(p1, Decl(typeGuardFunction.ts, 77, 44))
>item : Symbol(item, Decl(typeGuardFunction.ts, 77, 49))
>item : Symbol(item, Decl(typeGuardFunction.ts, 77, 49))
>A : Symbol(A, Decl(typeGuardFunction.ts, 0, 0))
acceptingTypeGuardFunction(isA);
>acceptingTypeGuardFunction : Symbol(acceptingTypeGuardFunction, Decl(typeGuardFunction.ts, 74, 25))
>isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1))
// Binary expressions
let union2: C | B;
>union2 : Symbol(union2, Decl(typeGuardFunction.ts, 81, 3))
>C : Symbol(C, Decl(typeGuardFunction.ts, 7, 1))
>B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1))
let union3: boolean | B = isA(union2) || union2;
>union3 : Symbol(union3, Decl(typeGuardFunction.ts, 82, 3))
>B : Symbol(B, Decl(typeGuardFunction.ts, 3, 1))
>isA : Symbol(isA, Decl(typeGuardFunction.ts, 11, 1))
>union2 : Symbol(union2, Decl(typeGuardFunction.ts, 81, 3))
>union2 : Symbol(union2, Decl(typeGuardFunction.ts, 81, 3))