Skip to content
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

computed property name in an interface error when using [] already #58179

Closed
eyebrowkang opened this issue Apr 13, 2024 · 3 comments
Closed

computed property name in an interface error when using [] already #58179

eyebrowkang opened this issue Apr 13, 2024 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@eyebrowkang
Copy link

πŸ”Ž Search Terms

A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.ts(1169)

πŸ•— Version & Regression Information

  • This changed between versions 3.3 and 5.4.5

⏯ Playground Link

https://www.typescriptlang.org/play?#code/KYOwrgtgBAouEwB4EMIAcA2woG8BQUhUA1sAJ4CMUAvFAOSmV0A0BRD5AtAM7ADGAexAATOjXqMe-IaNYBfPHgCWIAC7AATgDNkfbAEk1mnXqSpM2fESgBtOJDPosAOkYUAugC4o3VRpUA5gDcbIR28I4WNhxkUoIidO5eUPAARpohCoRAA

πŸ’» Code

enum EnumExample {
    key1 = 'key1',
    'key-second' = 'key-second',
}

interface InterfaceExample {
    [EnumExample.key1]: string;
    [EnumExample['key-second']]: number;
}

πŸ™ Actual behavior

Has Error: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.ts(1169)

πŸ™‚ Expected behavior

No Error

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

MartinJohns commented Apr 13, 2024

Duplicate of #25083. Used search terms: enum computed property name

@jcalz
Copy link
Contributor

jcalz commented Apr 13, 2024

Regression information is incorrect; this didn’t change between TS3.3 and current (it didn’t work in TS3.3 either).

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 15, 2024
@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 Apr 18, 2024
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

5 participants