Closed
Description
TypeScript Version: 2.3.2
Code
function fn(): void {}
export type MyType = number;
when compiled with a default tsconfig.json
emits
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function fn() {
}
Expected behavior:
It should not emit
Object.defineProperty(exports, "__esModule", { value: true });
if exports
is not emitted in the compiled module.
Actual behavior:
Object.defineProperty(...)
is emitted even if exports
is not defined for the compiled module. When this code is loaded in a browser, it will throw an exception: Uncaught ReferenceError: exports is not defined
.
If the MyType
type declaration in the above code is not exported, then Object.defineProperty(...)
is not emitted.