-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES Module imports discarded when they include a type and a side-effect #28285
Comments
Duplicate of #9191 I imagine. |
@weswigham Certainly looks like it, only this is explicit ESNext modules and #9191 is referencing Only
#9191 has been sitting round for years without a fix because finding out whether the reference includes a side effect is incredibly difficult. However this could be fixed by adding a special case for ESNext when an explicit As a fix for this wouldn't necessarily be a fix for #9191 does this still count as a duplicate? Especially as #9191 is never going to get fixed ( |
Even if the import includes |
@weswigham yes, so for TS the extension is optional, but for JS missing the extension will throw an error. The only reason to include the extension in TS is because you want the Imports with explicit |
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:
Code
tsconfig.json
target ESNextsource-component.ts
with anexport
and a side effectmissing-import.ts
that references the dependency as a type and expects the side effectExpected behaviour:
When output to
missing-import.js
the reference should be retained:An import as a side effect would be acceptable too:
Actual behaviour:
The
import
is stripped out:Workaround:
Duplicate side effect
import
statements are retained:The text was updated successfully, but these errors were encountered: