Skip to content

Commit eceebe9

Browse files
committed
instanceOf: disable dev instanceOf checks if NODE_ENV not set
development behavior should be opt in, not opt out graphql#4075 (comment)
1 parent 6c56e05 commit eceebe9

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Diff for: .mocharc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ extension:
55
- ts
66
node-option:
77
- 'loader=ts-node/esm/transpile-only'
8+
require:
9+
- './resources/mochaFixture.ts'

Diff for: resources/mochaFixture.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export async function mochaGlobalSetup() {
2+
process.env.NODE_ENV = 'development';
3+
}

Diff for: src/jsutils/instanceOf.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { inspect } from './inspect.js';
22

33
/* c8 ignore next 3 */
4-
const isProduction =
4+
const isDevelopment =
55
globalThis.process != null &&
66
// eslint-disable-next-line no-undef
7-
process.env.NODE_ENV === 'production';
7+
process.env.NODE_ENV === 'development';
88

99
/**
1010
* A replacement for instanceof which includes an error warning when multi-realm
@@ -15,11 +15,8 @@ const isProduction =
1515
export const instanceOf: (value: unknown, constructor: Constructor) => boolean =
1616
/* c8 ignore next 6 */
1717
// FIXME: https://github.com/graphql/graphql-js/issues/2317
18-
isProduction
18+
isDevelopment
1919
? function instanceOf(value: unknown, constructor: Constructor): boolean {
20-
return value instanceof constructor;
21-
}
22-
: function instanceOf(value: unknown, constructor: Constructor): boolean {
2320
if (value instanceof constructor) {
2421
return true;
2522
}
@@ -50,6 +47,9 @@ spurious results.`,
5047
}
5148
}
5249
return false;
50+
}
51+
: function instanceOf(value: unknown, constructor: Constructor): boolean {
52+
return value instanceof constructor;
5353
};
5454

5555
interface Constructor extends Function {

0 commit comments

Comments
 (0)