-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
export import generates no code (perhaps due optimization) #512
Comments
This appears to be a bug in the old compiler. The new compiler generates the following b.js in both cases: // b.js
exports.c = require("c"); |
What version have you mentioned? npm version is 1.0.1 and it has that bug. |
The compiler version in the master branch right now. It is not published in npm yet. |
I spent several hours tonight dealing with this problem and trying to track it down online, so +1 for getting it to prod ASAP. Is there an ETA for public release of this version? I couldn't find anything on the roadmap or elsewhere. |
@nexussays I would say soon https://github.com/Microsoft/TypeScript/milestones |
Are new versions cut from master, so this fix will be part of 1.1? There's no milestone on this issue and no associated changelog. |
@nexussays, yes master would be the right place to grab the fix for this. |
Great. Can't wait for 1.1 :) |
TLDR: TypeScript does not generate JS code for exported variables when they are not used in current compilation scope, only the declarations (.d.ts)
Example
source files
Success scenario
. We are usinga.ts
directly.tsc a.ts --module commonjs
generated files
Failure scenario
. Imagine if a.ts is placed into another project and uses b.ts as external dependency. In that case we need to compile b.ts with declarations for it.tsc b.ts --module commonjs --declaration
First, this behavior is strongly inconsistent since generated declarations contains definitions for code that does not exist in generated JS.
Also, the fact that the JS code does not get generated at all is a blocker for our current use cases.
We need this fixed as soon as possible.
The text was updated successfully, but these errors were encountered: