* unknownify accesses * Move to simplify to break less with fewer changes * Accept baselines for now * Always propegate any as an index type * Fix flow control in the presence of simplifiable types * Add spy repro from #25181 * Retain errorType when it is used as a marker for the lack of a constraint * Small refinement * Add new test * Move most potentially recursive types from isIdenticalTo into structuredTypeRelatedTo to match the non-identity relations * Fix nits * Doesnt need to be undefineable at all
23 lines
564 B
TypeScript
23 lines
564 B
TypeScript
interface Spy {
|
|
(...params: any[]): any;
|
|
|
|
identity: string;
|
|
and: Function;
|
|
mostRecentCall: { args: any[]; };
|
|
argsForCall: any[];
|
|
}
|
|
|
|
type SpyObj<T> = T & {
|
|
[k in keyof T]: Spy;
|
|
}
|
|
|
|
declare function createSpyObj<T>(
|
|
name: string, names: Array<keyof T>): SpyObj<T>;
|
|
|
|
function mock<T>(spyName: string, methodNames: Array<keyof T>): SpyObj<T> {
|
|
const spyObj = createSpyObj<T>(spyName, methodNames);
|
|
for (const methodName of methodNames) {
|
|
spyObj[methodName].and.returnValue(1);
|
|
}
|
|
return spyObj;
|
|
} |