Skip to content

Instantly share code, notes, and snippets.

@balanza
Created January 30, 2019 20:25
Show Gist options
  • Save balanza/edb5d2e21f987ca8db4ec8b68cca3df9 to your computer and use it in GitHub Desktop.
Save balanza/edb5d2e21f987ca8db4ec8b68cca3df9 to your computer and use it in GitHub Desktop.
const exhaustionCheck = (e: never) => console.log('this will never be executed')
const printMobileSafe = (mobile: Mobile) => {
if(mobile.status === 'confirmed') {
console.log('Your mobile is confirmed!')
} else if(mobile.status === 'unconfirmed') {
console.warn('Your mobile is not confirmed!')
} else {
exhaustionCheck(mobile) // <-- you'll get a compilation error here!
}
}
const certified: CertifiedMobile = { status: 'certified', value: '543234531' }
printMobileSafe(certified)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment