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

Proposal: Declaring an enum restricted by a number,string or boolean set #3105

Closed
jbondc opened this issue May 10, 2015 · 5 comments
Closed
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript

Comments

@jbondc
Copy link
Contributor

jbondc commented May 10, 2015

Withdrawn

@jbondc jbondc changed the title Proposal: Declarating a enum restricted by a set of number/numeric literals Proposal: Declarating an enum restricted by a set of number/numeric literals May 10, 2015
@jbondc jbondc changed the title Proposal: Declarating an enum restricted by a set of number/numeric literals Proposal: Declaring an enum restricted by a set of number/numeric literals May 11, 2015
@danquirk
Copy link
Member

I'm not sure this adds enough value for the complexity it introduces. Are there any other languages that support this kind of feature? It just adds bounds checking to numeric enums but doesn't scale to other enum spaces. We've had requests for string based enums for example which couldn't use this, we use bit flag enums ourselves a lot, and it's not unreasonable to imagine 'illegal' values within a contiguous bound which this wouldn't protect against.

@danquirk danquirk added the Suggestion An idea for TypeScript label May 11, 2015
@jbondc jbondc changed the title Proposal: Declaring an enum restricted by a set of number/numeric literals Proposal: Declaring an enum restricted by a number,string or boolean set May 12, 2015
@jbondc
Copy link
Contributor Author

jbondc commented May 13, 2015

@danquirk About your mention of other languages, made a weird discovery Pascal has 'set types':
http://en.wikipedia.org/wiki/Pascal_(programming_language)#Set_types

Updated the proposal with links. This should be super familiar to @ahejlsberg 😮

@Gaelan
Copy link

Gaelan commented Sep 23, 2015

@danquirk "a" | "b" | "c" syntax would be insanely helpful for writing .d.ts files (lots of JS libraries use magic strings).

@mhegazy mhegazy added the Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. label Dec 9, 2015
@jbondc jbondc closed this as completed Dec 10, 2015
@Gaelan
Copy link

Gaelan commented Dec 10, 2015

@jbondc Why the withdrawal? This was a good idea.

@jbondc
Copy link
Contributor Author

jbondc commented Dec 11, 2015

@Gaelan I'm sure the TS team will come up with something. I've left the link to set types, maybe they will call it collection types or something. When philosophies diverge too much, it's best to part ways.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants