TypeScript Version: I'm using the ts checker with javascript in VS Code so I'm not 100% sure on the version I'm using.
Search Terms:
RegExpExecArray
RegExpExecArray groups
exec groups
regex groups
Code
// GF116 [GeForce GTX 550 Ti] --> GeForce GTX 550 Ti
const regex = new RegExp(/.+\[(?<gpuname>.+)\]/);
regex.exec('GF116 [GeForce GTX 550 Ti]').groups.gpuname;
Expected behavior:
No error.
Actual behavior:
Property 'groups' does not exist on type 'RegExpExecArray'.ts(2339)
Related Issues:
https://github.com/Microsoft/TypeScript/issues/17094
Duplicate of #29465.
edit: .. or not? The other issue is about RegExprMatchArray. Not sure what the difference is.
@MartinJohns looks like RegExpExecArray also needs the fix.
Trying the stackblitz from that issue with this code still shows this.
Property 'groups' does not exist on type 'RegExpExecArray'.
// GF116 [GeForce GTX 550 Ti] --> GeForce GTX 550 Ti
const regex = new RegExp(/.+\[(?<gpuname>.+)\]/);
regex.exec('GF116 [GeForce GTX 550 Ti]').groups.gpuname;
Trying the stackblitz from that issue with this code still shows this.
The issue explicitly says that the Stackblitz website is using outdated versions...
When you set your target to es2018, then your code works. https://github.com/Microsoft/TypeScript/issues/29465#issuecomment-455489648
Trying this on the playground again no longer works. I tried es2018, es2019, es2020 and esnext.
Version: v3.9.0-dev.20200407
Config:

const regex = new RegExp(/^.+: ID (?<id>\S+)(?<name>.*)$/);
const line = 'test string';
const groups = regex.exec(line)?.groups;
Hovering over ?.groups shows "Property 'groups' does not exist on type 'RegExpExecArray'.(2339)".
Same on 3.9.3 for me.
For now, i'm doing something like this:
type AdjustedRegex = RegExpExecArray & { groups: {} };
const matches = regex.exec(line) as AdjustedRegex;
This is still an issue. Can it please be reopened?
Still an issue, target & lib => 2020
@RyanCavanaugh please reopen this.
Most helpful comment
@RyanCavanaugh please reopen this.