google / google/closure-compiler
Type Only Import Reference
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
A key component to avoiding circular dependencies is the option to reference a type without importing the module.
Example:
``` js
import ModelEvent from './model-event';
export default class Model extends EventTarget {
changeItem(item) {
this.item = item;
this.dispatchEvent(new ModelEvent('change:'+item.name, this, item));
}
}
```
``` js
import Model from './model';
export default class ModelEvent extends Event {
/**
* @param {string|!goog.events.EventId} type Event Type.
* @param {!Model} model
*/
constructor(type, model) {
}
}
```
We need a way (without requiring closure-library) to import or reference a type from another module.
Contributor guide
Assessment
This issue has not been assessed yet.