react-spectrum
react-spectrum copied to clipboard
@internationalized: named regexp capture groups cause build failure in TypeScript 5.5
Provide a general summary of the issue here
Related: #4542
Currently, the regular expression DATE_TIME_DURATION_RE in date/src/string.ts uses named capture groups, which are then subsequently referenced as match.groups....
This syntax was not supported prior to ES2018, and the upcoming TypeScript 5.5 release adds checks to validate regular expression flags and syntax against the build target. The result is error TS1503: Named capturing groups are only available when targeting 'ES2018' or later., causing the build to fail.
💁 Possible Solution
There are two resolution options:
- Update the project's build target to
ES2018(orESNextetc.) - Remove the named capture group syntax from
DATE_TIME_DURATION_RE, and reference the matched groups by index rather than by group name (ie.match[...]rather thanmatch.groups...). This is already the approach used with the other regular expressions in string.ts.