镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@jbondc

Withdrawn

Activity

  1. 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[/+] on May 10, 2015
  2. 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[/+] on May 11, 2015
  3. danquirk commented on May 11, 2015

    @danquirk
    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.

  4. 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[/+] on May 12, 2015
  5. jbondc commented on May 13, 2015

    @jbondc
    ContributorAuthor

    Dan Quirk (@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 Anders Hejlsberg (@ahejlsberg) 😮

  6. Gaelan commented on Sep 23, 2015

    @Gaelan

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

  7. added
    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.
    on Dec 9, 2015
  8. Gaelan commented on Dec 10, 2015

    @Gaelan

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

  9. jbondc commented on Dec 11, 2015

    @jbondc
    ContributorAuthor

    Gaelan Steele (@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.

  10. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions