react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

@internationalized: named regexp capture groups cause build failure in TypeScript 5.5

Open Renegade334 opened this issue 1 year ago • 0 comments

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:

  1. Update the project's build target to ES2018 (or ESNext etc.)
  2. 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 than match.groups...). This is already the approach used with the other regular expressions in string.ts.

Renegade334 avatar May 11 '24 19:05 Renegade334