Skip to content

Commit 823d311

Browse files
committed
Avoid optional chaining in instanceOf to achieve 100% coverage.
1 parent db4b2b8 commit 823d311

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/jsutils/instanceOf.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default process.env.NODE_ENV === 'production'
2323
return true;
2424
}
2525
if (value) {
26-
const classTag = constructor?.prototype?.[SYMBOL_TO_STRING_TAG];
26+
const proto = constructor && constructor.prototype;
27+
const classTag = proto && proto[SYMBOL_TO_STRING_TAG];
2728
const className = classTag || constructor.name;
2829
// When the constructor class defines a Symbol.toStringTag
2930
// property, as most classes exported by graphql-js do, use it
@@ -38,7 +39,7 @@ export default process.env.NODE_ENV === 'production'
3839
// value is legitimately _not_ instanceof constructor.
3940
const valueName = classTag
4041
? value[SYMBOL_TO_STRING_TAG]
41-
: value.constructor?.name;
42+
: value.constructor && value.constructor.name;
4243
if (typeof className === 'string' && valueName === className) {
4344
throw new Error(
4445
`Cannot use ${className} "${value}" from another module or realm.

0 commit comments

Comments
 (0)