I'm getting Property 'groups' does not exist on type 'RegExpExecArray' when trying
const r = /\w+, (?<foo>\w+)/
const m = r.exec('hello, world')
if (m) {
const groups = m.groups
}
Javascript has an option to call .groups on a regex exec result. And I know the output is actually an array... but grabbing a specific index to get the groups seems a bit hacky. Is pulling from the list the only option in Typescript?
RegExpExecArrayis missing a type definition for thegroupsproperty in TS.RegExpMatchArray, but since it's anArray, if I usem["groups"]TS generates errorElement implicitly has an 'any' type because index expression is not of type 'number'.And if I usem.groups, then I gotProperty 'groups' does not exist on type 'RegExpMatchArray'.