google / google/closure-compiler
Property that is a class is not type checkable without being marked as @const
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Suppose `collection.js`:
```js
export class A {}
export default {A}
```
and `index.js`:
```js
import {A} from './collection.js';
import collection from './collection.js';
class B extends A {}
class C extends collection.A {}
```
Compiling this produces a warning:
```
$ closure-compiler --js collection.js --js index.js --warning_level VERBOSE --checks_only
index.js: WARNING - Bad type annotation. Unknown type $jscompDefaultExport$$module$collection.A
0 error(s), 1 warning(s), 92.5% typed
```
`closure-compiler` is the latest java release.
```
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20180716
Built on: 2018-07-17 22:09
```
Class `B` that extends explicitly imported `A` works fine, but class `C` that extends `A` imported as a property of `default` object produces warning.
The code compiles and works as expected despite the warning.
Also note that the warning is missing line information and is not pointing to any particular point in the code. There weren't any annotations in original code either, so the message is quite misleading.
Referencing `collection.A` in jsdoc annotations also produces a warning:
```
WARNING - Bad type annotation. Unknown type collection$$module$collection.A
* @type {collection.A}
^
```
This might to be related to https://github.com/google/closure-compiler/issues/2236 and/or https://github.com/google/closure-compiler/issues/2257 but I could not reproduce the former with the current version of compiler while the latter issue seems to be explicitly about transitive exports.
Contributor guide
Assessment
This issue has not been assessed yet.