JS Type Checker Wish List: Regex validated strings
type HexColor = /#[0-9a-f]+/i;
const color: HexColor = '#eee'; // fine
const color: HexColor = 'red'; // error!
-
-
We have it implemented in a branch but apart from the "make sure you pass in only these strings" case which is really compelling, thinking about how you narrow other strings for validation feels off. It means you have to write the same regex in both expression & type positions.
- 10 more replies
New conversation
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 