Skip to content
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

MockFunction return type may be generic #169

Closed
cawa-93 opened this issue Sep 29, 2022 · 4 comments
Closed

MockFunction return type may be generic #169

cawa-93 opened this issue Sep 29, 2022 · 4 comments

Comments

@cawa-93
Copy link

cawa-93 commented Sep 29, 2022

type MockFunction = {

It allows you type mocked module like so:

const myModule = await esmock<typeof import('/module/path')>('/module/path')
@cawa-93
Copy link
Author

cawa-93 commented Sep 29, 2022

cc: @jsejcksn

@iambumblehead
Copy link
Owner

is the issue that, the new typescript types file is forcing you to define <typeof import('/module/path')>? should we revert the esmock.d.ts?

@cawa-93
Copy link
Author

cawa-93 commented Sep 29, 2022

No. It's enhansment. Currently esmock('module/path') return any and user will not get code intellisense. Type resolution from module may be automated if microsoft/TypeScript#31090 will be resolved.

Actually, I just realise, that user can set type just like: 🤦🏻‍♂️

const myModule: typeof import('/module/path') = await esmock('/module/path')

So, I close this as no actual, until microsoft/TypeScript#31090 was resolved

@cawa-93 cawa-93 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2022
@iambumblehead
Copy link
Owner

@cawa-93 thanks for sharing that is great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants