microsoft / microsoft/TypeScript

`Object` variable declaration conflicts on commonjs

Open
#35,478 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: JS Emit
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test path is named. Start by compiling the provided TypeScript repro with CommonJS output and compare the emitted JavaScript with the expected behavior; done means the declaration no longer causes the reported ReferenceError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.