-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
When an ES module syntax import has an explicit type and a side effect it is excluded from the output JS.
TypeScript Version: 3.2.0-dev.20181101
Search Terms:
- ES Modules
- Module resolution
Code
tsconfig.jsontarget ESNext
{
"compilerOptions": {
"target": "esnext",
"module": "esnext"
}
}source-component.tswith anexportand a side effect
export class SourceComponent extends HTMLElement {
// Web component implementation
}
customElements.define('source-component', SourceComponent);missing-import.tsthat references the dependency as a type and expects the side effect
import {SourceComponent} from './source-component.js';
const example = document.createElement('source-component') as SourceComponent;Expected behaviour:
When output to missing-import.js the reference should be retained:
import {SourceComponent} from './source-component.js';
const example = document.createElement('source-component');An import as a side effect would be acceptable too:
import './source-component.js';
const example = document.createElement('source-component');Actual behaviour:
The import is stripped out:
const example = document.createElement('source-component');Workaround:
Duplicate side effect import statements are retained:
import {SourceComponent} from './source-component.js';
import './source-component.js';
const example = document.createElement('source-component') as SourceComponent;Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created