Skip to content

Commit

Permalink
Merge pull request #2004 from satanTime/issues/985
Browse files Browse the repository at this point in the history
fix(core): generic in getMockedNgDefOf #985
  • Loading branch information
satanTime authored Mar 7, 2022
2 parents 7214131 + 567908d commit 9c3717b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/ng-mocks/src/lib/common/func.get-mocked-ng-def-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function getMockedNgDefOf<T>(declaration: AnyType<T>, type: 'p'): Type<Mo
*
* @see https://ng-mocks.sudo.eu/api/helpers/getMockedNgDefOf
*/
export function getMockedNgDefOf(declaration: AnyType<any>): Type<any>;
export function getMockedNgDefOf<T>(declaration: AnyType<T>): Type<T>;

export function getMockedNgDefOf(declaration: any, type?: any): any {
const source = declaration.mockOf ? declaration.mockOf : declaration;
Expand Down
12 changes: 12 additions & 0 deletions tests-failures/get-mocked-ng-def-of.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getMockedNgDefOf, Type } from 'ng-mocks';

declare class Expected {
public name: string;
}

declare class Actual {
public name: number;
}

// @ts-expect-error: string is not boolean
const result: Type<Actual> = getMockedNgDefOf(Expected);

0 comments on commit 9c3717b

Please sign in to comment.