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.
As a temporary workaround, you can name your class _Object
and write export { _Object as Object }
This should be an error, similar to the error we issue if you declare your own _this
.
PRs welcomed.