TypeScript Version: 2.3.2
Code
export interface A {
a: boolean,
b: number,
c: string
}
Expected behavior:
It is not expected to be transpiled to JS code in any way if it is the only thing that is exported
Actual behavior:
It is transpiled to an empty module, like this for example:
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
});
A .ts file will always result in a .js file. Not emitting a file makes it hard to track issues like a stale .js file generated frim previous builds.
If you do not want any files generated change it to a .d.ts.
Ok, thanks for the explanation, I will definitely try the d.ts solution, but can this be implemented something like a tree shaking process on bundle creation?
The compiler already elides imports that are only used in type position. So this file should never be imported at runtime.
We have discussed bundling in the past and the conclusion was that there are already abundance of bundlers, minifiers, optimizers and the like in the community and there is no reason to introduce yet another tool.
Ok, thanks for the information.
Most helpful comment
The compiler already elides imports that are only used in type position. So this file should never be imported at runtime.
We have discussed bundling in the past and the conclusion was that there are already abundance of bundlers, minifiers, optimizers and the like in the community and there is no reason to introduce yet another tool.