From 7f2731ef8bebac7f226cfc0d2446854603a557a9 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Mon, 20 Jun 2022 09:49:04 +0300 Subject: [PATCH] fix(jest-runtime): avoid star type import from `@jest/globals` (#12949) --- CHANGELOG.md | 2 ++ packages/jest-runtime/src/index.ts | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86894862782e..edd253da566b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +-`[jest-runtime]` Avoid star type import from `@jest/globals` ([#12949](https://github.com/facebook/jest/pull/12949)) + ### Chore & Maintenance - `[docs]` Mention that jest-codemods now supports Sinon ([#12898](https://github.com/facebook/jest/pull/12898)) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index b2a08df90b7c..5b9f869bc55a 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -32,7 +32,7 @@ import type { ModuleWrapper, } from '@jest/environment'; import type {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; -import type * as JestGlobals from '@jest/globals'; +import type {expect, jest} from '@jest/globals'; import type {SourceMapRegistry} from '@jest/source-map'; import type { RuntimeTransformResult, @@ -69,11 +69,11 @@ const dataURIRegex = /^data:(?text\/javascript|application\/json|application\/wasm)(?:;(?charset=utf-8|base64))?,(?.*)$/; interface JestGlobals extends Global.TestFrameworkGlobals { - expect: typeof JestGlobals.expect; + expect: typeof expect; } interface JestGlobalsWithJest extends JestGlobals { - jest: typeof JestGlobals.jest; + jest: typeof jest; } type HasteMapOptions = { @@ -2331,7 +2331,7 @@ export default class Runtime { beforeAll: this._environment.global.beforeAll, beforeEach: this._environment.global.beforeEach, describe: this._environment.global.describe, - expect: this._environment.global.expect as any, + expect: this._environment.global.expect as typeof expect, fdescribe: this._environment.global.fdescribe, fit: this._environment.global.fit, it: this._environment.global.it,