From a65bc9ed59f555eaa8ff2c6b06e3a6fbfa76e3ea Mon Sep 17 00:00:00 2001 From: Ulf Winkelvos Date: Tue, 7 Nov 2023 15:10:21 +0100 Subject: [PATCH 1/2] typings: make MockFunction generic this allows esmock to be used in a more convenient way in typescript setups ``` import esmock from 'esmock'; import type * as moduleUnderTest from './moduleUnderTest.js'; const { func } = await esmock( './moduleUnderTest.js', import.meta.url, { //... }, ); const actual = await func(); ``` --- src/esmock.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/esmock.d.ts b/src/esmock.d.ts index 7bbabfd..1a8baf5 100644 --- a/src/esmock.d.ts +++ b/src/esmock.d.ts @@ -22,19 +22,19 @@ type MockFunction = { * @param opts * @returns The mocked import-tree result of "import({@link modulePath})" */ - ( + ( modulePath: string, parent: string, defs?: MockMap, gdefs?: MockMap, opts?: Options - ): any, - ( + ): Promise, + ( modulePath: string, defs?: MockMap, gdefs?: MockMap, opts?: Options - ): any + ): Promise } /** From 994a02fd0db71d58b64a499d21b6c0232927059a Mon Sep 17 00:00:00 2001 From: Ulf Winkelvos Date: Tue, 7 Nov 2023 16:47:58 +0100 Subject: [PATCH 2/2] make generic default to any --- src/esmock.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/esmock.d.ts b/src/esmock.d.ts index 1a8baf5..6e17319 100644 --- a/src/esmock.d.ts +++ b/src/esmock.d.ts @@ -22,14 +22,14 @@ type MockFunction = { * @param opts * @returns The mocked import-tree result of "import({@link modulePath})" */ - ( + ( modulePath: string, parent: string, defs?: MockMap, gdefs?: MockMap, opts?: Options ): Promise, - ( + ( modulePath: string, defs?: MockMap, gdefs?: MockMap,