Last active
March 19, 2021 00:52
-
-
Save ericwooley/6e7722104d42bb87cd42fa1e13ef4cd0 to your computer and use it in GitHub Desktop.
Extract explanation
This file contains 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
// states of h2o | |
type h2o = 'water'|'steam'|'ice' | |
// states of h2o that will pass through a filter | |
type filter = 'water'|'steam' | |
// Extract non solid forms of h2o | |
type nonSolidH2o = Extract<h2o, filter> | |
// these are fine, they are not solid | |
const water: nonSolidH2o = 'water' | |
const steam: nonSolidH2o = 'steam' | |
// ice should error, because it cannot pass through a filter | |
// @ts-expect-error | |
const ice: nonSolidH2o = 'ice' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment