Skip to content

In a modular context, when an enum uses another-enum as its value, the enum be Reverse mappings #56206

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

Closed
shaddollxz opened this issue Oct 24, 2023 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@shaddollxz
Copy link

shaddollxz commented Oct 24, 2023

πŸ”Ž Search Terms

"enum" "revers mappings" "module"

πŸ•— Version & Regression Information

typescript: 5.2.2
vite: 4.4.7 or nextjs: 13.5.6
react: 18.2.0
vue: 3.3.4

⏯ Playground Link

https://codesandbox.io/s/amazing-mcclintock-j6s48r?file=/src/App.tsx

πŸ’» Code

// enum.ts
export enum Map {
  A = 'a',
  B = 'b',
}
// index.ts
import { Map } from './enum'
enum NewMap {
  KeyA = Map.A
}

console.log(NewMap) // { KeyA: "a", a: "KeyA" }

πŸ™ Actual behavior

NewMap is a reverse mappings enum

πŸ™‚ Expected behavior

NewMap not revers, like { keyA: 'a' }

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Oct 24, 2023
@RyanCavanaugh
Copy link
Member

#56153 (comment)

@fatcerberus
Copy link

fatcerberus commented Oct 24, 2023

Hmm, but that comment only says this would be an error under isolatedModules. Here, even without isolatedModules (where this will presumably continue to be allowed), it's emitting a reverse mapping for a string-valued member, which seems wrong.

@RyanCavanaugh
Copy link
Member

Codesandbox appears to be using single-file transpile and thus should turn on isolatedModules. The whole-program tsc emit is correctly unidirectional.

@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants