3 ms·
Sure, now make it work without having to type "\\w"
by wredcoll 1y ago
Sure, now make it work without having to type "\\w"
- deleted 1y ago[deleted]
- ssalbdivad 1y agoYes, there are limits on what string literals can precisely represent, but we've tried to be pragmatic about trade offs around clarity, concision and performance. Subexpressions like `\\w` or `[a-Z]` would just be inferred as `${string}`, but that doesn't mean the inference won't be useful. For example: expression: regex("^\\w+@\\w+\\.\\w+$") type: Regex<`${string}@${string}.${string}`>
- wredcoll 1y agoCan't you use tagged literals to do something similar?
- ssalbdivad 1y agoNot sure exactly what you mean by "something similar".
- wredcoll 1y agoThe issue is not being able to type actual regexes: /\w+[a-z]$/ becomes something different when enclosed in double quotes.