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 #291

Closed
mttrbrts opened this issue Jul 3, 2021 · 2 comments
Closed

Extending Enums #291

mttrbrts opened this issue Jul 3, 2021 · 2 comments

Comments

@mttrbrts
Copy link
Member

mttrbrts commented Jul 3, 2021

Feature Request πŸ›οΈ

I want to prompt a discussion about the extension of enumerated types as a feature in a type systems

Use Case

Consider the following...

enum Foo {
 o A
 o B
}

enum Bar extends Foo {
  o C
}

Alternative

An alternative solution would be to allow a users define new types through copying rather than extension. E.g.

enum Bar {
  ...Foo
  o C
}

Context

This discussion for the same feature in TypeScript is useful reference, microsoft/TypeScript#17592

In summary, the main objection seems to be the loss of the "closed" property of Enums. With enum extension, client code looses the quality that it can be sure of complete coverage of members.

@jeromesimeon
Copy link
Member

Indeed we could use inheritance. The cost being some complexity in code using enums that may have to support annotations when building values. How important is this feature really?

@mttrbrts
Copy link
Member Author

Closing due to lack of motivating use cases

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

No branches or pull requests

2 participants