Navigation Menu

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

Export of enum typedef doesn't pass e2e test #50

Closed
evmar opened this issue Feb 8, 2016 · 1 comment
Closed

Export of enum typedef doesn't pass e2e test #50

evmar opened this issue Feb 8, 2016 · 1 comment

Comments

@evmar
Copy link
Contributor

evmar commented Feb 8, 2016

If we generate code like the following, it fails to compile in Closure:

/** @typedef {number} */
export var EnumTest2;
(function (EnumTest2) {
    EnumTest2[EnumTest2["XYZ"] = 0] = "XYZ";
    EnumTest2[EnumTest2["PI"] = 3.14159] = "PI";
})(EnumTest2 || (EnumTest2 = {}));
/** @type {EnumTest2} */
EnumTest2.XYZ = 0;  // <- ***fails here***
/** @type {EnumTest2} */
EnumTest2.PI = 3.14159;

The error message:

[...] ERROR - Bad type annotation. Unknown type EnumTest2
/** @type {EnumTest2} */
           ^

Something about export and typedef interacting poorly maybe?

The other weird thing is that I can't reproduce this with the Google-internal JS compiler, which makes me wonder if it's a bug.

@evmar
Copy link
Contributor Author

evmar commented Feb 8, 2016

(This is different than our existing "enum" test in that it uses export enum ..., which puts an extra export in the above output.)

evmar added a commit that referenced this issue Feb 8, 2016
If you wrote "export enum ...", the generated ES6 JavaScript would
fail to compile in the Closure compiler.  I tracked this down to
a bug that was fixed in the upstream Closure compiler, so to fix
this I had to make us use a newer version of the upstream compiler.

To use a newer version of the upstream compiler, I removed one of
our indirection layers: we previously used the 'closure-compiler'
npm library which pulled in 'google-closure-compiler', but now the
latter module exposes a simple API so it's easy enough to just use
it directly.

Fixes issue #50.
@evmar evmar closed this as completed Feb 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant