Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exported interface is transpiled to empty module #15950

Closed
micnic opened this issue May 19, 2017 · 4 comments
Closed

Exported interface is transpiled to empty module #15950

micnic opened this issue May 19, 2017 · 4 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@micnic
Copy link
Contributor

micnic commented May 19, 2017

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 });
    ;
});
@mhegazy
Copy link
Contributor

mhegazy commented May 20, 2017

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.

@micnic
Copy link
Contributor Author

micnic commented May 20, 2017

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?

@mhegazy
Copy link
Contributor

mhegazy commented May 20, 2017

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.

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label May 20, 2017
@micnic
Copy link
Contributor Author

micnic commented May 22, 2017

Ok, thanks for the information.

@micnic micnic closed this as completed May 22, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

2 participants