google / google/closure-compiler
es6 modules + import alias + closure enum
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I'm trying to import one es6 module from another and have noticed that if I do that *and* provide an alias to the original module, I get odd behaviour when an enum is involved. For example, compiling files one.js and two.js works fine, but one.js and three.js yields a warning from closure. Is this a bug in closure or in my understanding of how it works?
$ cat one.js
export class X { }
/** @enum {string} */
export const Foo = { BAR: "bar", }
$ cat two.js
import {X,Foo} from 'one';
/** @param {X} a */
function f1(a) { }
/** @param {Foo} b */
function f2(b) { }
$ java -jar closure-compiler-v20170124.jar --js='one.js' --js='two.js' --warning_level=VERBOSE > /dev/null
$ cat three.js
import * as lib from 'one';
/** @param {lib.X} a */
function f1(a) { }
/** @param {lib.Foo} b */
function f2(b) { }
$ java -jar closure-compiler-v20170124.jar --js='one.js' --js='three.js' --warning_level=VERBOSE > /dev/null
three.js:6: WARNING - Bad type annotation. Unknown type module$one.Foo
/** @param {lib.Foo} b */
^
0 error(s), 1 warning(s), 100.0% typed
$
Contributor guide
Assessment
This issue has not been assessed yet.