Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module with "Object" export has bad ES5 emit #17494

Closed
jeffreymorlan opened this issue Jul 28, 2017 · 3 comments
Closed

Module with "Object" export has bad ES5 emit #17494

jeffreymorlan opened this issue Jul 28, 2017 · 3 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@jeffreymorlan
Copy link
Contributor

TypeScript Version: 2.2 to current

Code
TS file:
export class Object {}
tsconfig.json:
{"compilerOptions": {"target": "es5"}}

Expected behavior:
The module should be able to initialize like it did in TypeScript 2.1.

Actual behavior:
Module fails to initialize; TypeError: Object is undefined.

The emitted code is

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Object = (function () {
    function Object() {
    }
    return Object;
}());
exports.Object = Object;

Clearly Object.defineProperty is intended to reference the global Object, but it gets an uninitialized local variable instead.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Jul 28, 2017
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.5 milestone Jul 28, 2017
@DanielRosenwasser
Copy link
Member

As a temporary workaround, you can name your class _Object and write export { _Object as Object }

@rbuckton
Copy link
Member

This should be an error, similar to the error we issue if you declare your own _this.

@DanielRosenwasser DanielRosenwasser removed the Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. label Jul 28, 2017
@mhegazy mhegazy assigned weswigham and unassigned rbuckton Aug 31, 2017
@weswigham weswigham added this to Not started in Rolling Work Tracking Sep 5, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.6, Community Oct 9, 2017
@mhegazy mhegazy added the Help Wanted You can do this label Oct 9, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 9, 2017

PRs welcomed.

Kingwl added a commit to Kingwl/TypeScript that referenced this issue Oct 13, 2017
Kingwl added a commit to Kingwl/TypeScript that referenced this issue Oct 13, 2017
Kingwl added a commit to Kingwl/TypeScript that referenced this issue Oct 13, 2017
Kingwl added a commit to Kingwl/TypeScript that referenced this issue Oct 14, 2017
Kingwl added a commit to Kingwl/TypeScript that referenced this issue Oct 17, 2017
Kingwl added a commit to Kingwl/TypeScript that referenced this issue May 24, 2018
@mhegazy mhegazy modified the milestones: Community, TypeScript 3.0 May 25, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 25, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
Rolling Work Tracking
  
Not started
Development

No branches or pull requests

5 participants