Skip to content

Commit a20454f

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

File tree

3 files changed

+175
-7
lines changed

3 files changed

+175
-7
lines changed

package-lock.json

+167
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"test": "npm run lint && npm run check && npm run testonly:cover && npm run prettier:check && npm run check:spelling && npm run check:integrations",
3838
"lint": "eslint --cache --max-warnings 0 --rulesdir resources/eslint-internal-rules/ .",
3939
"check": "tsc --pretty",
40-
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts",
40+
"testonly": "dotenvx run --env NODE_ENV=development -- mocha --full-trace src/**/__tests__/**/*-test.ts",
4141
"testonly:cover": "c8 npm run testonly",
4242
"testonly:watch": "npm run testonly -- --watch",
4343
"prettier": "prettier --cache --cache-strategy metadata --write --list-different .",
@@ -56,6 +56,7 @@
5656
"devDependencies": {
5757
"@docusaurus/core": "3.5.2",
5858
"@docusaurus/preset-classic": "3.5.2",
59+
"@dotenvx/dotenvx": "^1.14.0",
5960
"@mdx-js/react": "3.0.1",
6061
"@svgr/webpack": "8.1.0",
6162
"@types/chai": "4.3.19",

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)