Last active
March 6, 2021 14:11
-
-
Save aiya000/dda615ac13c3016df946f2de591606eb 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
/** | |
* The type 'true' means a proof is satisfied. | |
* The type 'never' means a proof is not satisfied. | |
*/ | |
// Basic of this idea. | |
type AWrongProof = { x: number } extends { x: string } ? true : never | |
// Compile NG | |
// const aWrongProof: AWrongProof = true | |
// Above is samea as below. | |
const thatIsWrong: AWrongProof extends never ? true : never = true | |
// Let's introduce that alias. | |
type Not<A extends true | never> = A extends never ? true : never | |
const thatIsWrong0: Not<AWrongProof> = true | |
// Unfortunately, this says: | |
// 2322: Type 'boolean' is not assignable to type 'never'. | |
/** | |
* Why? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment