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
|
=== tests/cases/compiler/spyComparisonChecking.ts ===
interface Spy {
(...params: any[]): any;
>params : any[]
identity: string;
>identity : string
and: Function;
>and : Function
mostRecentCall: { args: any[]; };
>mostRecentCall : { args: any[]; }
>args : any[]
argsForCall: any[];
>argsForCall : any[]
}
type SpyObj<T> = T & {
>SpyObj : SpyObj<T>
[k in keyof T]: Spy;
}
declare function createSpyObj<T>(
>createSpyObj : <T>(name: string, names: Array<keyof T>) => SpyObj<T>
name: string, names: Array<keyof T>): SpyObj<T>;
>name : string
>names : (keyof T)[]
function mock<T>(spyName: string, methodNames: Array<keyof T>): SpyObj<T> {
>mock : <T>(spyName: string, methodNames: Array<keyof T>) => SpyObj<T>
>spyName : string
>methodNames : (keyof T)[]
const spyObj = createSpyObj<T>(spyName, methodNames);
>spyObj : SpyObj<T>
>createSpyObj<T>(spyName, methodNames) : SpyObj<T>
>createSpyObj : <T>(name: string, names: (keyof T)[]) => SpyObj<T>
>spyName : string
>methodNames : (keyof T)[]
for (const methodName of methodNames) {
>methodName : keyof T
>methodNames : (keyof T)[]
spyObj[methodName].and.returnValue(1);
>spyObj[methodName].and.returnValue(1) : any
>spyObj[methodName].and.returnValue : any
>spyObj[methodName].and : Function
>spyObj[methodName] : SpyObj<T>[keyof T]
>spyObj : SpyObj<T>
>methodName : keyof T
>and : Function
>returnValue : any
>1 : 1
}
return spyObj;
>spyObj : SpyObj<T>
}
|