Skip to content

Commit

Permalink
fix: fix ts-expect-error in src/index.ts
Browse files Browse the repository at this point in the history
StanHannebelle committed Jan 21, 2022

Verified

This commit was signed with the committer’s verified signature.
StanHannebelle Stan Hannebelle
1 parent 3cde12b commit 02f9b74
Showing 3 changed files with 12 additions and 6 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/assertions/utils/globalTypeChecker.ts
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;
14 changes: 8 additions & 6 deletions src/index.ts
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";

0 comments on commit 02f9b74

Please sign in to comment.