Description
Edit: Since someone is complaining about the failure to follow issue templates, I copied the content to #3432 (comment). Please continue the discussion in that issue.
Original content
Previously worked on #51837, I found that TypeScript gives almost no syntax errors for regular expressions. I would like to file a PR about it, thus I am opening this issue for easier tracking.
But before I work on the issue, I would like to hear some opinions from the Team. I am not sure, but I suppose the job of providing syntax check should not be shirked to linters right?
Something I would like to do are:
- Check for duplicated or unknown flags
- Check for unbalanced parentheses, which is the most common mistake people make
- Check for invalid escapes
But this should be done only for RegExps withu
orv
flag, i.e. inUnicodeMode
, that means if we encounter au
orv
flag we will need to rescan the whole RegExp again (!!) (i.e. redoing what is done in the currentreScanSlashToken
method)
And to check for invalidDecimalEscape
s and k<GroupName>
s we will also need to count the number of capture groups and record the names of all named capture groups along the way.
Am I doing too much or too less? I know doing too much may cause serious performace regressions (well, luckily regular expression literals are not that common compared with string literals). It should be better than doing nothing after all though.