-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Feature]: Export MockedObject & similar utility types? #12784
Comments
Did you check these from Documentation is missing, but seems to be exposed. Or these aren’t exactly what you need? |
I think those are exactly what I need, yes and thank you! +1 to documentation existing -- I'd assumed |
Current I work on #12727. It will add |
Documenting that all the mock types are available from |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
@SimenB From the user's perspective it is very hard to discover what types are available in which internal jest-[whatever] package because you as a user of jest don't even know those packages like jest-mock are installed because they are not a peer dependency, but rather a direct dependency. I would like jest to reexport all TS types in the main jest package so it is easy to look for/import those types rather than scanning through jest's overwhelming number of dependencies. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
From #12856 (comment) #12727 landed recently adding refreshed (see #13123) utility types @JoshuaKGoldberg @alesmenzel Just wanted to ask – are there any other types you would find useful? (Or any use cases where typing becomes cumbersome?) |
This looks like all I'd need for now, thank you very much! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Could TypeScript types such as
MockedObject
please be exported from some package that consumers would have access to while using the@jest/globals
package?Motivation
It'd be convenient for declaring types of objects that contain mocks. Right now there's now easy way to declare in the type system that an object is a
MockedObject<T>
for anyT
object type.Example
In typescript-eslint/tslint-to-eslint-config#1458 I'm trying to get the TypeScript types to work for a
createStubWritableStream
function that returns a mocked version of aNodeJS.WritableStream
. Here's a minimum reproduction in the TypeScript playground.Pitch
MockedObject
isn't exported in any way I can find -nor documented on the website-. There's no way to declare the return type ofcreateStubWritableStream
-or variables that store that value type- to beMockedObject<NodeJS.WritableStream>
.Even if I'm using
jest.fn()
and/or the types wrong, being able to refer toMockedObject<...>
is quite useful for debugging type system woes such as this one.The text was updated successfully, but these errors were encountered: