Last active
February 1, 2019 08:20
-
-
Save balanza/f7e927d40d8f8ed51f9609fa1d1877d5 to your computer and use it in GitHub Desktop.
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 ConfirmedMobile = string & { __random_transparent_property: never } | |
type UnconfirmedMobile = string & { __another_random_transparent_property: never } | |
type CertifiedMobile = string & { __again_random_transparent_property: never } | |
type Mobile = // ConfirmedMobile | UnconfirmedMobile | CertifiedMobile :) | |
ConfirmedMobile | |
| UnconfirmedMobile | |
| CertifiedMobile | |
const printString = (p: string) => console.log(`print String ${p}`) | |
const printConfirmedMobile = (p: ConfirmedMobile) => console.log(`print ConfirmedMobile ${p}`) | |
printString('foo') | |
// ^^^ ok | |
printConfirmedMobile('foo') | |
// ^^^ compilation error: cannot assign 'foo' to type ConfirmedMobile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment