import { SpyInternalImpl } from 'tinyspy'; interface MockResultReturn { type: 'return'; value: T; } interface MockResultIncomplete { type: 'incomplete'; value: undefined; } interface MockResultThrow { type: 'throw'; value: any; } type MockResult = MockResultReturn | MockResultThrow | MockResultIncomplete; interface MockContext { calls: TArgs[]; instances: TReturns[]; invocationCallOrder: number[]; results: MockResult[]; lastCall: TArgs | undefined; } type Procedure = (...args: any[]) => any; type Methods = { [K in keyof T]: T[K] extends Procedure ? K : never; }[keyof T] & (string | symbol); type Properties = { [K in keyof T]: T[K] extends Procedure ? never : K; }[keyof T] & (string | symbol); type Classes = { [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never; }[keyof T] & (string | symbol); interface SpyInstance { getMockName(): string; mockName(n: string): this; mock: MockContext; mockClear(): this; mockReset(): this; mockRestore(): void; getMockImplementation(): ((...args: TArgs) => TReturns) | undefined; mockImplementation(fn: ((...args: TArgs) => TReturns) | (() => Promise)): this; mockImplementationOnce(fn: ((...args: TArgs) => TReturns) | (() => Promise)): this; withImplementation(fn: ((...args: TArgs) => TReturns), cb: () => T): T extends Promise ? Promise : this; mockReturnThis(): this; mockReturnValue(obj: TReturns): this; mockReturnValueOnce(obj: TReturns): this; mockResolvedValue(obj: Awaited): this; mockResolvedValueOnce(obj: Awaited): this; mockRejectedValue(obj: any): this; mockRejectedValueOnce(obj: any): this; } interface MockInstance extends SpyInstance { } interface Mock extends SpyInstance { new (...args: TArgs): TReturns; (...args: TArgs): TReturns; } interface PartialMock extends SpyInstance> ? Promise>> : Partial> { new (...args: TArgs): TReturns; (...args: TArgs): TReturns; } type MaybeMockedConstructor = T extends new (...args: Array) => infer R ? Mock, R> : T; type MockedFunction = Mock, ReturnType> & { [K in keyof T]: T[K]; }; type PartiallyMockedFunction = PartialMock, ReturnType> & { [K in keyof T]: T[K]; }; type MockedFunctionDeep = Mock, ReturnType> & MockedObjectDeep; type PartiallyMockedFunctionDeep = PartialMock, ReturnType> & MockedObjectDeep; type MockedObject = MaybeMockedConstructor & { [K in Methods]: T[K] extends Procedure ? MockedFunction : T[K]; } & { [K in Properties]: T[K]; }; type MockedObjectDeep = MaybeMockedConstructor & { [K in Methods]: T[K] extends Procedure ? MockedFunctionDeep : T[K]; } & { [K in Properties]: MaybeMockedDeep; }; type MaybeMockedDeep = T extends Procedure ? MockedFunctionDeep : T extends object ? MockedObjectDeep : T; type MaybePartiallyMockedDeep = T extends Procedure ? PartiallyMockedFunctionDeep : T extends object ? MockedObjectDeep : T; type MaybeMocked = T extends Procedure ? MockedFunction : T extends object ? MockedObject : T; type MaybePartiallyMocked = T extends Procedure ? PartiallyMockedFunction : T extends object ? MockedObject : T; interface Constructable { new (...args: any[]): any; } type MockedClass = MockInstance any ? P : never, InstanceType> & { prototype: T extends { prototype: any; } ? Mocked : never; } & T; type Mocked = { [P in keyof T]: T[P] extends (...args: infer Args) => infer Returns ? MockInstance : T[P] extends Constructable ? MockedClass : T[P]; } & T; type EnhancedSpy = SpyInstance & SpyInternalImpl; declare const spies: Set>; declare function isMockFunction(fn: any): fn is EnhancedSpy; declare function spyOn>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>; declare function spyOn>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>; declare function spyOn> | Methods>)>(obj: T, methodName: M): Required[M] extends ({ new (...args: infer A): infer R; }) | ((...args: infer A) => infer R) ? SpyInstance : never; declare function fn(): Mock; declare function fn(implementation: (...args: TArgs) => R): Mock; export { EnhancedSpy, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, PartialMock, PartiallyMockedFunction, PartiallyMockedFunctionDeep, SpyInstance, fn, isMockFunction, spies, spyOn };