request: add accompanying importsNotUsedAsValues
option for declaration imports
#44519
Open
5 tasks done
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
I'm looking for the ability to instruct the compiler to preserve imports as 'side-effecting' for declaration files. I'm framing this request in terms of the existing
importsNotUsedAsValues
option for sake of clarity but this is for declarations only.I suspect it may require a new accompanying option to
importsNotUsedAsValues
called, .e.g.,declarationImportsAsSideEffects
🔍 Search Terms
✅ Viability Checklist
⭐ Suggestion
Based on the existing
importsNotUsedAsValues
behaviour, imports are emitted to.js
to varying degrees. This proposal would ensure that there are accompanying imports within emitted.d.ts
files to the same degree. For imports that are value-only and preserved, a "side effecting"import './a-module'
would be emitted; others would remain as is📃 Motivating Example
Compiling yields (tested 4.3.2 with
importsNotUsedAsValues='preserve'
)Currently, if another module were to import
plugin-loader
:Note that the augmentation type (global/module) doesn't matter, just that they're included
💻 Use Cases
What do you want to use this for?
Enable plugin architectures where augmentations can be reliably expected to have been reached
What workarounds are you using in the meantime?
"Shadow" side-effect imports to ensure declarations include
import
What shortcomings exist with current (workaround) approach?
The text was updated successfully, but these errors were encountered: