google / google/closure-compiler

Type Only Import Reference

Open
#1,736 16 comments 5 reactions 0 assignees View on GitHub
Documentation triage-done
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.