Better typing support for ES2015 symbols #11736
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
An interesting usage of ES2015's
symbol
is using it as a replacement for string/integer constants. An usage example would be:However, this causes the issue that you can't specify what symbols are accepted. This could be resolved by using string constants, for example:
I propose another option which would allow you to continue to use
symbol
s instead of string constants: specify the acceptedsymbol
s in the type signature. It could look like this:This has the advantage of looking very similar to string constants but still allowing you to use
symbol
s.The text was updated successfully, but these errors were encountered: