Skip to content

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

@jeffreymorlan

Description

@jeffreymorlan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions