-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix ts-expect-error in src/index.ts
1 parent
3cde12b
commit 02f9b74
Showing
3 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type GlobalWithExpectKey = { expect: any }; | ||
export const isGlobalWithExpectKey = ( | ||
global: any | ||
): global is GlobalWithExpectKey => "expect" in global; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import matchers from "./assertions"; | ||
import { isGlobalWithExpectKey } from "./assertions/utils/globalTypeChecker"; | ||
|
||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'expect' does not exist on type 'Global &... Remove this comment to see the full error message | ||
const jestExpect = global.expect; | ||
if (isGlobalWithExpectKey(global)) { | ||
const jestExpect = global.expect; | ||
|
||
if (jestExpect !== undefined) { | ||
jestExpect.extend(matchers); | ||
} else { | ||
console.error("Unable to find Jest's global expect."); | ||
if (jestExpect !== undefined) { | ||
jestExpect.extend(matchers); | ||
} else { | ||
console.error("Unable to find Jest's global expect."); | ||
} | ||
} | ||
|
||
export * from "./helpers"; |