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

Extract out test environment global types #494

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Feb 7, 2023

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, e.g.

{
  "compilerOptions": {
    "target": "esnext",
    "lib": ["esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "types": [
      "@cloudflare/workers-types",
      "vitest-environment-miniflare/globals"
    ]
  }
}

Closes #94
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
@mrbbot mrbbot requested a review from penalosa February 7, 2023 16:50
@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2023

⚠️ No Changeset found

Latest commit: 48e828c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, but needs a changeset

@mrbbot mrbbot merged commit e5e314c into master Feb 13, 2023
@mrbbot mrbbot deleted the bcoll/test-environment-global-types branch February 13, 2023 21:47
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

Successfully merging this pull request may close these issues.

Helper types for Jest
2 participants