Skip to content

Commit 1cc0a36

Browse files
committed
fix(jest): fix for incorrect typing of SpyObject for Jest
1 parent 49d61e9 commit 1cc0a36

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

projects/spectator/jest/src/mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Provider, Type } from '@angular/core';
22
import { CompatibleSpy, SpyObject as BaseSpyObject, installProtoMethods } from '@netbasal/spectator';
33

4-
export type SpyObject<T> = BaseSpyObject<T> & { [P in keyof T]: T[P] & jest.Mock<T> };
4+
export type SpyObject<T> = BaseSpyObject<T> & { [P in keyof T]: T[P] & (T[P] extends (...args: any[]) => infer R ? jest.Mock<R> : T[P]) };
55

66
export function createSpyObject<T>(type: Type<T>, template?: Partial<Record<keyof T, any>>): SpyObject<T> {
77
const mock: any = template || {};

projects/spectator/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
"jquery": "3.3.1",
2828
"schematics-utilities": "^1.1.1"
2929
},
30+
"peerDependencies": {
31+
"typescript": ">= 2.8.0"
32+
},
3033
"schematics": "./schematics/collection.json"
3134
}

0 commit comments

Comments
 (0)