From bb0a14e75e57420932e421d4cb0c3a151fc934e6 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Thu, 26 Jan 2017 18:17:44 +0100 Subject: [PATCH] Removed redunant intersection --- jest/index.d.ts | 10 ++++++---- jest/jest-tests.ts | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index acfe70a0f6..6e204db890 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -32,7 +32,9 @@ declare namespace jest { function autoMockOff(): typeof jest; /** Enables automatic mocking in the module loader. */ function autoMockOn(): typeof jest; - /** @deprecated */ + /** + * @deprecated use resetAllMocks instead + */ function clearAllMocks(): typeof jest; /** Clears the mock.calls and mock.instances properties of all mocks. Equivalent to calling .mockClear() on every mocked function. */ function resetAllMocks(): typeof jest; @@ -124,7 +126,7 @@ declare namespace jest { ensureExpectedIsNumber(actual: any, matcherName?: string): void; ensureNoExpected(actual: any, matcherName?: string): void; ensureNumbers(actual: any, expected: any, matcherName?: string): void; - /** get the type of a value with handling the edge cases like `typeof []` and `typeof null` */ + /** get the type of a value with handling of edge cases like `typeof []` and `typeof null` */ getType(value: any): string; matcherHint(matcherName: string, received?: string, expected?: string, options?: { secondArgument?: string, isDirectExpectCall?: boolean }): string; pluralize(word: string, count: number): string; @@ -142,7 +144,7 @@ declare namespace jest { interface Expect { (actual: any): Matchers; anything(): void; - any(cs: any): void; + any(classType: any): void; arrayContaining(arr: any[]): void; assertions(num: number): void; extend(obj: ExpectExtendMap): void; @@ -202,7 +204,7 @@ declare namespace jest { * const myApi: jest.Mocked = new Api() as any; * myApi.myApiMethod.mockImplementation(() => "test"); */ - type Mocked = T & { + type Mocked = { [P in keyof T]: T[P] & MockInstance; }; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index d2fcd6d007..0cc6089ca8 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -434,12 +434,16 @@ class TestApi { declare function mockedFunc(a: number): string; +declare function mockedFuncWithApi(api: TestApi): void; + describe('Mocked type', function () { it('Works', function () { const mock: jest.Mocked = new TestApi() as any; mock.testProp; mock.testMethod.mockImplementation(() => 'test'); mock.testMethod(5).toUpperCase(); + + mockedFuncWithApi(mock); }); });