declare const S: unique symbol; interface GetState { (spy: SpyInternalImpl): SpyInternalImplState; (spy: SpyInternal): SpyInternalState; } declare let spies: Set>; declare let getInternalState: GetState; declare type ReturnError = ['error', any]; declare type ReturnOk = ['ok', R]; declare type ResultFn = ReturnError | ReturnOk; interface SpyInternal { (this: any, ...args: A): R; [S]: SpyInternalState; } interface SpyInternalImpl extends SpyInternal { [S]: SpyInternalImplState; } interface SpyInternalState { called: boolean; callCount: number; calls: A[]; results: ResultFn[]; reset(): void; impl: ((...args: A) => R) | undefined; next: ResultFn[]; } interface SpyInternalImplState extends SpyInternalState { getOriginal(): (...args: A) => R; willCall(cb: (...args: A) => R): this; restore(): void; } interface Spy extends SpyInternalState { returns: R[]; length: number; nextError(error: any): this; nextResult(result: R): this; } interface SpyImpl extends Spy { getOriginal(): (...args: A) => R; willCall(cb: (...args: A) => R): this; restore(): void; } declare function createInternalSpy(cb?: ((...args: A) => R) | { new (...args: A): R; }): SpyInternal; interface SpyFn extends Spy { new (...args: A): R extends void ? any : R; (...args: A): R; } declare function spy(cb?: ((...args: A) => R) | { new (...args: A): R; }): SpyFn; declare type Procedure = (...args: any[]) => any; declare type Methods = { [K in keyof T]: T[K] extends Procedure ? K : never; }[keyof T]; declare type Getters = { [K in keyof T]: T[K] extends Procedure ? never : K; }[keyof T]; declare type Constructors = { [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never; }[keyof T]; declare function internalSpyOn(obj: T, methodName: K | { getter: K; } | { setter: K; }, mock?: Procedure): SpyInternalImpl; declare function spyOn>>(obj: T, methodName: { setter: S; }, mock?: (arg: T[S]) => void): SpyImpl<[T[S]], void>; declare function spyOn>>(obj: T, methodName: { getter: G; }, mock?: () => T[G]): SpyImpl<[], T[G]>; declare function spyOn>>(object: T, method: M): Required[M] extends new (...args: infer A) => infer R ? SpyImpl : never; declare function spyOn>>(obj: T, methodName: M, mock?: T[M]): Required[M] extends (...args: infer A) => infer R ? SpyImpl : never; declare function restoreAll(): void; export { Spy, SpyFn, SpyImpl, SpyInternal, SpyInternalImpl, createInternalSpy, getInternalState, internalSpyOn, restoreAll, spies, spy, spyOn };