I'm currently converting a project to use the new es6 module style (which is really a great feature!). The compiler removes all references to modules I'm using only typing information from which makes absolutely sense. However, when accessing a constant enumeration the require call will be preserved in js output although it is not needed, e.g.:
a.ts
export const enum MyEnum {
ValueA,
ValueB,
ValueC
}
b.ts
import * as a from "./a";
export var myValue = a.MyEnum.ValueB;
Now, b.ts compiles to this, note the unnecessary require call:
b.js
var a = require("./a");
exports.myValue = 1;
First I thought this is my fault but then I tried to use the imported types solely as type arguments which results in the compiler removing the require call correctly, e.g.:
c.ts
import * as a from "./a";
export function myFunction(value:a.MyEnum):string {
return "myReturn";
}
Will compile to this:
c.js
function myFunction(value) {
return "myReturn";
}
exports.myFunction = myFunction;
I'm currently converting a project to use the new es6 module style (which is really a great feature!). The compiler removes all references to modules I'm using only typing information from which makes absolutely sense. However, when accessing a constant enumeration the require call will be preserved in js output although it is not needed, e.g.:
a.ts
b.ts
Now,
b.tscompiles to this, note the unnecessaryrequirecall:b.js
First I thought this is my fault but then I tried to use the imported types solely as type arguments which results in the compiler removing the require call correctly, e.g.:
c.ts
Will compile to this:
c.js