[type] identifier 'global' has already been declared
See original GitHub issueFails to require @deepkit/type
in a jest test suite, because global
is a “reserved” identifier.
/node_modules/@deepkit/type/dist/cjs/src/model.js:23
const global = {
^
SyntaxError: Identifier 'global' has already been declared
at Runtime.createScriptFromCode (../../../../../../../../../../node_modules/jest-runtime/build/index.js:1350:14)
at Object.<anonymous> (../../../../../../../../../../node_modules/@deepkit/type/index.ts:12:1)
Here’s a quick fix for now using patch-package
:
diff --git a/node_modules/@deepkit/type/dist/cjs/src/model.js b/node_modules/@deepkit/type/dist/cjs/src/model.js
index 5f1fec9..f6cdbce 100644
--- a/node_modules/@deepkit/type/dist/cjs/src/model.js
+++ b/node_modules/@deepkit/type/dist/cjs/src/model.js
@@ -20,11 +20,9 @@ var UnpopulatedCheck;
UnpopulatedCheck[UnpopulatedCheck["Throw"] = 1] = "Throw";
UnpopulatedCheck[UnpopulatedCheck["ReturnSymbol"] = 2] = "ReturnSymbol";
})(UnpopulatedCheck = exports.UnpopulatedCheck || (exports.UnpopulatedCheck = {}));
-const global = {
- RegisteredEntities: {},
- unpopulatedCheck: UnpopulatedCheck.Throw,
- enableForwardRefDetection: true,
-};
+global.RegisteredEntities = {};
+global.unpopulatedCheck = UnpopulatedCheck.Throw;
+global.enableForwardRefDetection = true;
function getGlobalStore() {
return global;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Identifier 'global' has already been declared #104 - GitHub
When running a test that imports the module, it causes a duplicate identifier error to be thrown. This seems to be the cause ......
Read more >jestjs - "Identifier 'global' has already been declared at ...
"Identifier 'global' has already been declared at compileFunction" error In jest tests after upgrading to monaco-editor 0.21.0.
Read more >Identifier "x" has already been declared" - Ep 11 - YouTube
JS Casts 11 - How to fix "Uncaught SyntaxError: Identifier "x" has already been declared " in JavaScript.
Read more >Getting a 'Uncaught SyntaxError: Identifier 'astrosUrl' has ...
Getting a 'Uncaught SyntaxError: Identifier 'astrosUrl' has already been declared. I don't know why I am getting this error as I don't see...
Read more >Uncaught SyntaxError: Identifier has already been declared ...
The "const ' {a}' has already been declared" error is thrown when JSHint encounters a constant declaration with an identifier that has already...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Mh ok, we can easily change that variable, no problemo.
is fixed in master