Created
June 17, 2017 10:18
-
-
Save gcanti/27647b6661a7f442ecc087f6ebb0f4f8 to your computer and use it in GitHub Desktop.
Functional TypeScript: Either vs Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Sobriety = 'Sober' | 'Tipsy' | 'Drunk' | 'Paralytic' | 'Unconscious' | |
type Gender = 'Male' | 'Female' | |
interface Person { | |
gender: Gender | |
age: number | |
clothes: Array<string> | |
sobriety: Sobriety | |
} | |
function mkPerson(gender: Gender, age: number, clothes: Array<string>, sobriety: Sobriety): Person { | |
return { | |
gender, | |
age, | |
clothes, | |
sobriety | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment