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

Extending Enums. #27947

Closed
4 tasks
guptaamol opened this issue Oct 17, 2018 · 3 comments
Closed
4 tasks

Extending Enums. #27947

guptaamol opened this issue Oct 17, 2018 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@guptaamol
Copy link

Search Terms

enums

Suggestion

I was hoping if there was a way to extends enums. Like in the example.

Use Cases

It would be really helpful for code reuse. And reduce errors.
I am not able to get this functionality, it would be really helpful if there exists a workaround for the same.

Examples

http://www.typescriptlang.org/play/#src=enum%20someEnum%20%7B%0D%0A%20%20%20%20a%20%3D%20'Some%20String'%2C%0D%0A%20%20%20%20b%20%3D%202%2C%0D%0A%7D%3B%0D%0A%0D%0Aenum%20extendedEnum%20%7B%0D%0A%20%20%20%20c%20%3D%20'string'%2C%0D%0A%20%20%20%20b%20%3D%20someEnum.b%20%2F%2F%20Gives%20Error%0D%0A%7D%0D%0A%0D%0Atype%20someEnumType%3CT%20extends%20someEnum%3E%20%3D%20T%20extends%20someEnum.a%20%3F%20string%20%3A%0D%0A%20%20%20%20T%20extends%20someEnum.b%20%3F%20number%20%3A%20never%3B%0D%0A%0D%0Atype%20extendedEnumType%3CT%20extends%20extendedEnum%3E%20%3D%0D%0A%20%20%20%20T%20extends%20extendedEnum.c%20%3F%20string%3A%20%20%20%20%20%20%20%20%20%20%2F%2F%20Gives%20Error%0D%0A%20%20%20%20T%20extends%20extendedEnum.b%20%3F%20number%20%3A%20never%3B%20%20%2F%2F%20Gives%20Error

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
@jack-williams
Copy link
Collaborator

Related or duplicate: #17592

@weswigham
Copy link
Member

weswigham commented Oct 17, 2018

Yeah, duplicate of #17592. Continue discussion there, if you so desire.

@weswigham weswigham added the Duplicate An existing issue was already created label Oct 17, 2018
@guptaamol
Copy link
Author

guptaamol commented Oct 18, 2018 via email

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

3 participants