-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typings: make MockFunction generic #267
Conversation
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<typeof moduleUnderTest>( './moduleUnderTest.js', import.meta.url, { //... }, ); const actual = await func(); ```
Btw thank you so much for creating this module @bumblehead! :) |
src/esmock.d.ts
Outdated
@@ -22,19 +22,19 @@ type MockFunction = { | |||
* @param opts | |||
* @returns The mocked import-tree result of "import({@link modulePath})" | |||
*/ | |||
( | |||
<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<T = any>, to keep 'any' type by default. Without '= any', esmock(...) result will be Promise<unknown>
@uwinkelvos thanks for the thanks --that makes me glad to read that. Its fine for me if @koshic publishes, but I'm going to publish now since it is not published. one moment... |
@iambumblehead just want you do decide - it's not an emergency case, so ) |
changes are published to v2.6.0 https://github.com/iambumblehead/esmock/releases/tag/v2.6.0 |
this allows esmock to be used in a more convenient way in typescript setups