From fd0775200e5b709ff3abdb875aa958c2684a791e Mon Sep 17 00:00:00 2001 From: Antoine Brault Date: Tue, 11 Dec 2018 14:21:36 -0500 Subject: [PATCH] use any instead of {} for mock return type --- types/jest/index.d.ts | 4 ++-- types/jest/jest-tests.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index b7486db0ac..89979493b7 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -763,12 +763,12 @@ declare namespace jest { new (...args: any[]): any; } - interface Mock extends Function, MockInstance { + interface Mock extends Function, MockInstance { new (...args: Y): T; (...args: Y): T; } - interface SpyInstance extends MockInstance {} + interface SpyInstance extends MockInstance {} /** * Wrap module with mock definitions diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 9054bddfa4..0b7b2c21d9 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -305,6 +305,9 @@ jest.fn().mockRestore(); const spiedTarget = { returnsVoid(): void { }, + setValue(value: string): void { + this.value = value; + }, returnsString(): string { return ""; } @@ -361,6 +364,9 @@ spy5.mockReturnValue('5'); // $ExpectType SpyInstance const spy6 = jest.spyOn(spiedTarget2, "value", "set"); +let spy7: jest.SpyInstance; +spy7 = jest.spyOn(spiedTarget, "setValue"); + /* Snapshot serialization */ const snapshotSerializerPlugin: jest.SnapshotSerializerPlugin = {