-
Notifications
You must be signed in to change notification settings - Fork 12.8k
verbatimModuleSyntax + import of ambient const enum missing error #48040
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
Comments
@andrewbranch what's your take? The linked PR has some additional context |
I think differentiating on ambient is highly problematic, though I understand why it’s tempting to do so. If we weren’t talking about the enigma of const enums specifically, it would be super wrong to consider ambience. Ambient declarations are assumed to exist in the same way non-ambient declarations exist, just in a location that the compiler doesn’t have direct knowledge of. Type-checking behavior should generally not be impacted by ambience; otherwise you’ll get different behavior between consuming .ts files and consuming the .d.ts outputs of those same files. Even more confusingly, in project references, you’ll get different behavior between the CLI and the editor, because the former uses .d.ts files for referenced projects while the latter defaults to using .ts files. The story changes slightly when talking about const enums, because when you
It’s really the project references scenario that makes me uncomfortable with this. Without other changes, you will be unable to consume your own preserved const enums from a referenced project with Summary:
|
@andrewbranch Thanks!
In other words this here proposal doesn't introduce any new issues? For the existing issue you mention, there's a solution without adding more information to declaration emit of const enums ... but it has problems with inlining referenced projects' enums? ... but maybe that can be worked around? It's a separate issue? |
This is still an issue for |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @jablko
Historical Information
|
Bug Report
preserveValueImports
doesn't error when you import an ambient const enum withisolatedModules
on. Instead you get an error at runtime.🩹 Proposed Solution
If the named import were a type vs. an ambient const enum, you'd get a compile-time error instead.
#47817 raises that error on ambient const enums, by changing its predicate to include ambient const enums.
🔍 Search Terms
preserveValueImports
ambient const enum🕗 Version & Regression Information
4.5.0-dev.20210909 - 4.7.0-dev.20220225
⏯️ Playground Link
Workbench Repro
🧑💻 Code
🙁 Actual Behavior
Runtime error:
🙂 Expected Behavior
Compile-time error (with #47817):
The text was updated successfully, but these errors were encountered: