TypeScript
TypeScript copied to clipboard
"export =" omission for const-enum-only modules is done too broadly
In 1.5, export = is not emitted if the symbol is a const-enum-only module. However, in any of the following cases, a const-enum-only module actually does have a runtime value and should be exported:
- the module is merged with a class
- the module is merged with a function
- the module is merged with a non-const enum
- --preserveConstEnums is enabled
For example, if this code is compiled with --module amd:
function foo() {}
module foo {
export const enum Id {}
}
export = foo;
it will emit:
define(["require", "exports"], function (require, exports) {
function foo() { }
// in 1.4, there was a "return foo;" here, but it is missing in 1.5
});