TypeScript silently omits enum assignment type error between two enums with the same name #55915
Labels
Breaking Change
Would introduce errors in existing code
Bug
A bug in TypeScript
Experimentation Needed
Someone needs to try this out to see what happens
Fix Available
A PR has been opened for this issue
Milestone
🔎 Search Terms
I'm not exactly sure what keywords to use for this because it's kind of a strange problem. Some ideas: enum assignment same name error missing
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
I couldn't do a playground link for this because it requires two separate files:
types.ts
diagnosticInformationMap.generated.ts
🙁 Actual behavior
There is no error if you import
DiagnosticCategory as DiagnosticCategory2
but there is an error if youDiagnosticCategory2 as DiagnosticCategory2
. Mytsconfig.json
for this experiment:Demo:
🙂 Expected behavior
I expected importing
DiagnosticCategory as DiagnosticCategory2
to cause the same error that importingDiagnosticCategory2 as DiagnosticCategory2
does. My rationale is that the two type definitions intypes.ts
appear to be identical to me, so my intuition tells me to expect them to behave identically. It seems to me like TypeScript is perhaps silently swallowing the error about assignment compatibility if the two types are named the same thing even though the names refer to two separate incompatible things from two separate files.Additional information about the issue
I discovered this confusing behavior while helping @jakebailey on #55894. It seemed like a bug to me so I'm reporting it here. Feel free to close this issue if this is expected behavior.
The text was updated successfully, but these errors were encountered: