-
Notifications
You must be signed in to change notification settings - Fork 209
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
getMiniflareFetchMock global type not defined #348
Comments
Hey! 👋 I agree these should be declared somewhere. They're actually here... miniflare/packages/jest-environment-miniflare/src/index.ts Lines 33 to 42 in 3e459b7
...but API Extractor, the tool we use for bundling type definitions, doesn't include them. 😢 I would suggest you declare them yourself like this: https://github.com/mrbbot/miniflare-typescript-esbuild-jest/blob/master/test/globals.d.ts Will have a think about this, but I suspect the quickest solution will be to manually define the I'm also going to close this as a duplicate of #94. |
Could this be fixed? Looks like it's just some configuration you need to do in the API Extractor. Anyone using this library with TypeScript hits this sooner or later. |
I just hit this today (in import type { MockAgent } from "undici";
declare const getMiniflareFetchMock: () => MockAgent; Which, yes, unfortunately means I had to add |
+1 a bit of a hassle to setup the types for jest environment ourselves |
Miniflare's Jest and Vitest environments define a few global helper functions. Previously, the global type augmentations for these functions were included with the implementations. Unfortunately, API extractor (the tool we use to bundle `*.d.ts` files), doesn't support bundling global augmentations (microsoft/rushstack#1176). This change extracts those augmentations into separate `globals.d.ts` files. This means users will be able to add `jest-environment-miniflare/globals` or `vitest-environment-miniflare/globals` to their `types` configuration and get these types in their environment. Ref #348
Miniflare's Jest and Vitest environments define a few global helper functions. Previously, the global type augmentations for these functions were included with the implementations. Unfortunately, API extractor (the tool we use to bundle `*.d.ts` files), doesn't support bundling global augmentations (microsoft/rushstack#1176). This change extracts those augmentations into separate `globals.d.ts` files. This means users will be able to add `jest-environment-miniflare/globals` or `vitest-environment-miniflare/globals` to their `types` configuration and get these types in their environment. Ref #348
When trying to use the new fetch mocking capability, it doesn't appear that the
getMiniflareFetchMock
global function has a type definition that's set up for end users to consume. I would expect that adding 'jest-environment-miniflare' to thecompilerOptions.types
array of my tsconfig would add that function to the global types, but it does not. Which makes sense because looking at theindex.d.ts
in the published npm module,getMiniflareFetchMock
is nowhere to be found.The text was updated successfully, but these errors were encountered: