Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gcanti/27647b6661a7f442ecc087f6ebb0f4f8 to your computer and use it in GitHub Desktop.
Save gcanti/27647b6661a7f442ecc087f6ebb0f4f8 to your computer and use it in GitHub Desktop.
Functional TypeScript: Either vs Validation
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