138 lines
2.3 KiB
Text
138 lines
2.3 KiB
Text
=== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionGenerics.ts ===
|
|
|
|
class A {
|
|
>A : A
|
|
|
|
propA: number;
|
|
>propA : number
|
|
}
|
|
|
|
class B {
|
|
>B : B
|
|
|
|
propB: number;
|
|
>propB : number
|
|
}
|
|
|
|
class C extends A {
|
|
>C : C
|
|
>A : A
|
|
|
|
propC: number;
|
|
>propC : number
|
|
}
|
|
|
|
declare function isB(p1): p1 is B;
|
|
>isB : (p1: any) => boolean
|
|
>p1 : any
|
|
>p1 : any
|
|
>B : B
|
|
|
|
declare function isC(p1): p1 is C;
|
|
>isC : (p1: any) => boolean
|
|
>p1 : any
|
|
>p1 : any
|
|
>C : C
|
|
|
|
declare function retC(x): C;
|
|
>retC : (x: any) => C
|
|
>x : any
|
|
>C : C
|
|
|
|
declare function funA<T>(p1: (p1) => T): T;
|
|
>funA : <T>(p1: (p1: any) => T) => T
|
|
>T : T
|
|
>p1 : (p1: any) => T
|
|
>p1 : any
|
|
>T : T
|
|
>T : T
|
|
|
|
declare function funB<T>(p1: (p1) => T, p2: any): p2 is T;
|
|
>funB : <T>(p1: (p1: any) => T, p2: any) => boolean
|
|
>T : T
|
|
>p1 : (p1: any) => T
|
|
>p1 : any
|
|
>T : T
|
|
>p2 : any
|
|
>p2 : any
|
|
>T : T
|
|
|
|
declare function funC<T>(p1: (p1) => p1 is T): T;
|
|
>funC : <T>(p1: (p1: any) => boolean) => T
|
|
>T : T
|
|
>p1 : (p1: any) => boolean
|
|
>p1 : any
|
|
>p1 : any
|
|
>T : T
|
|
>T : T
|
|
|
|
declare function funD<T>(p1: (p1) => p1 is T, p2: any): p2 is T;
|
|
>funD : <T>(p1: (p1: any) => boolean, p2: any) => boolean
|
|
>T : T
|
|
>p1 : (p1: any) => boolean
|
|
>p1 : any
|
|
>p1 : any
|
|
>T : T
|
|
>p2 : any
|
|
>p2 : any
|
|
>T : T
|
|
|
|
declare function funE<T, U>(p1: (p1) => p1 is T, p2: U): T;
|
|
>funE : <T, U>(p1: (p1: any) => boolean, p2: U) => T
|
|
>T : T
|
|
>U : U
|
|
>p1 : (p1: any) => boolean
|
|
>p1 : any
|
|
>p1 : any
|
|
>T : T
|
|
>p2 : U
|
|
>U : U
|
|
>T : T
|
|
|
|
let a: A;
|
|
>a : A
|
|
>A : A
|
|
|
|
let test1: boolean = funA(isB);
|
|
>test1 : boolean
|
|
>funA(isB) : boolean
|
|
>funA : <T>(p1: (p1: any) => T) => T
|
|
>isB : (p1: any) => boolean
|
|
|
|
if (funB(retC, a)) {
|
|
>funB(retC, a) : boolean
|
|
>funB : <T>(p1: (p1: any) => T, p2: any) => boolean
|
|
>retC : (x: any) => C
|
|
>a : A
|
|
|
|
a.propC;
|
|
>a.propC : number
|
|
>a : C
|
|
>propC : number
|
|
}
|
|
let test2: B = funC(isB);
|
|
>test2 : B
|
|
>B : B
|
|
>funC(isB) : B
|
|
>funC : <T>(p1: (p1: any) => boolean) => T
|
|
>isB : (p1: any) => boolean
|
|
|
|
if (funD(isC, a)) {
|
|
>funD(isC, a) : boolean
|
|
>funD : <T>(p1: (p1: any) => boolean, p2: any) => boolean
|
|
>isC : (p1: any) => boolean
|
|
>a : A
|
|
|
|
a.propC;
|
|
>a.propC : number
|
|
>a : C
|
|
>propC : number
|
|
}
|
|
let test3: B = funE(isB, 1);
|
|
>test3 : B
|
|
>B : B
|
|
>funE(isB, 1) : B
|
|
>funE : <T, U>(p1: (p1: any) => boolean, p2: U) => T
|
|
>isB : (p1: any) => boolean
|
|
>1 : number
|
|
|