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

Symbols disallowed as object keys #39756

Closed
ghost opened this issue Jul 27, 2020 · 3 comments
Closed

Symbols disallowed as object keys #39756

ghost opened this issue Jul 27, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 27, 2020

TypeScript Version: 4.0.0-dev.20200725

Search Terms:
Symbols as object keys

Code

type symbolKey = {
    [key: symbol]: any
};

Expected behavior:
The code compiles without error.

Actual behavior:
TSC throws an error disallowing symbols to be used as object keys.

Playground Link: https://www.typescriptlang.org/play?ts=4.0.0-dev.20200725#code/C4TwDgpgBAziC2AjA9gGwNIRFAvFA3gFBQlQDaA1lgFywIqoC6tAhgHYiEC+A3EA

Related Issues: Couldn't find anything related

Symbols were introduces with the primary purpose of being used as object keys, and are still primarily, if not only, used with that purpose. To not be usable as keys makes no sense whatsoever. They can be used on any object type too, array, generic object, map, Element, etc.

@SancheZz
Copy link

#26797

@kitsonk
Copy link
Contributor

kitsonk commented Jul 28, 2020

Duplicate of #1863

@ghost ghost closed this as completed Jul 28, 2020
@ghost
Copy link
Author

ghost commented Jul 28, 2020

Yeah okay, I'm a bit late.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants