`Object` variable declaration conflicts on commonjs
See original GitHub issueTypeScript Version: 3.7.x-dev.20191203
Search Terms:
Code
export default {}
const Object = {};
Expected behavior:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
{
exports.default = {};
const Object = {};
}
no error
Actual behavior:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {};
const Object = {};
VM69:2 Uncaught ReferenceError: Cannot access 'Object' before initialization
at eval (eval at <anonymous> (main-3.js:1239), <anonymous>:2:1)
at main-3.js:1239
Playground Link: http://www.typescriptlang.org/play/index.html?module=1#code/KYDwDg9gTgLgBAE2AMwIYFcA28DeBfAKAGMIA7AZ3gHkAjAK2CPgF458BuIA
Related Issues:
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Documentation - Modules - TypeScript
Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export keyword.
Read more >Fortran Modules - Variable declarations conflict in module with ...
I have a FORTRAN 95 code where, in the main program, these variables are declared: integer :: ...
Read more >JavaScript modules - MDN Web Docs
... other CommonJS and AMD-based module systems like RequireJS, ... Returns an object containing the canvas's 2D context and the wrapper's ...
Read more >CommonJS modules | Node.js v19.3.0 Documentation
Functions and objects are added to the root of a module by specifying additional properties on the special exports object. Variables local to...
Read more >TypeScript errors and how to fix them
error TS1117: An object literal cannot have multiple properties with the ... error TS2440: Import declaration conflicts with local declaration of ' React...
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
Note that you must not make
import { Object } from '...'
an error because it won’t be a runtime error.Node.js is a user of this technique too.
https://github.com/nodejs/node/search?l=JavaScript&q=primordials+Object