Skip to content

Object variable declaration conflicts on commonjs #35478

Open
@falsandtru

Description

@falsandtru

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions