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

Add enum support #366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Commits on Jan 4, 2021

  1. Add enum support

    The `enum` is a popular aspect of TypeScript, and can be embedded in
    interfaces as a concise, but descriptive, shorthand for literal string
    unions:
    
    ```typescript
    enum Colour {
      White = '000000',
      Black = 'ffffff'
    }
    ```
    
    This change adds an exported member `enum` to `io-ts`, based on
    [this suggestion][1] by @noe132
    
    It means that `enum`s can be reused directly in `io-ts`:
    
    ```typescript
    const T = t.enum(Colour)
    ```
    
    [1]: gcanti#216 (comment)
    Alec Gibson committed Jan 4, 2021
    Configuration menu
    Copy the full SHA
    a048fbd View commit details
    Browse the repository at this point in the history