question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Object` variable declaration conflicts on commonjs

See original GitHub issue

TypeScript 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:open
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
falsandtrucommented, Jan 29, 2020

Note that you must not make import { Object } from '...' an error because it won’t be a runtime error.

0reactions
falsandtrucommented, Jan 27, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found