Skip to content

ES2018 RegExp named capture groups not supported with esnext library #22082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
slikts opened this issue Feb 21, 2018 · 3 comments
Closed

ES2018 RegExp named capture groups not supported with esnext library #22082

slikts opened this issue Feb 21, 2018 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@slikts
Copy link

slikts commented Feb 21, 2018

TypeScript Version: 2.8.0-dev.20180221

Search Terms: RegExp named capture groups; description

Code

'foo'.match(/(?<bar>foo)/)!.groups

Expected behavior:
It should compile with esnext (ES2018) library compiler option.

Actual behavior:
Property 'groups' does not exist on type 'RegExpMatchArray'.

Playground Link:

Related Issues:

@slikts
Copy link
Author

slikts commented Feb 21, 2018

The fix seems to be as simple as:

interface RegExpMatchArray {
  groups?: {
    [key: string]: string
  }
}

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this Good First Issue Well scoped, documented and has the green light labels Feb 21, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Feb 21, 2018

A PR would be appreciated. We will need a new file src\lib\es2018.regexp.d.ts with the new declaration, and then we will need that wired in jakeFile.js.

@mhegazy mhegazy self-assigned this Feb 21, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Feb 21, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 1, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Mar 1, 2018

thanks @YuichiNukiyama !

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants