Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 6e7901a

Browse files
committed
Add ExecutionContext as global _value_ to test environment types
Miniflare injects the `ExecutionContext` class into its unit testing environments, so they can be constructed and passed to imported module event handlers. Previously, this type was only available as an `interface` from `@cloudflare/workers-types`, causing a type error whenever it was constructed. With this change, it's now declared as a value when including `{jest,vitest}-environment-miniflare/globals` in the `tsconfig.json` `types` array.
1 parent 96bcc93 commit 6e7901a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/shared-test-environment/globals.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ declare global {
7878
function getMiniflareDurableObjectIds(
7979
namespace: string
8080
): Promise<DurableObjectId[]>;
81+
82+
// eslint-disable-next-line no-var
83+
var ExecutionContext: {
84+
prototype: ExecutionContext;
85+
new (): ExecutionContext;
86+
};
8187
}
8288

8389
// Taken from `undici` (https://github.com/nodejs/undici/tree/main/types) with

0 commit comments

Comments
 (0)