Skip to content

Node now supports Regexp hasIndices -- typescript does not. #44227

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
BobFrankston opened this issue May 24, 2021 · 2 comments Β· Fixed by #52085
Closed

Node now supports Regexp hasIndices -- typescript does not. #44227

BobFrankston opened this issue May 24, 2021 · 2 comments Β· Fixed by #52085
Assignees
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript ES Next New featurers for ECMAScript (a.k.a. ESNext) Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone Suggestion An idea for TypeScript

Comments

@BobFrankston
Copy link

Bug Report

πŸ”Ž hasIndices

Node 16 supports indices, TypeScript does not.

πŸ•— Version & Regression Information

When I discovered the feature in Node 16

⏯ Playground Link

 /(a)/d.exec('a').indices

πŸ™ Actual behavior

In Node it works

WIth Typescript, it is flagged as an error

πŸ™‚ Expected behavior

New features. await support in ESNext.

@BobFrankston BobFrankston changed the title Node now supports regexp hasIndices -- typescript deos not. Node now supports Regexp hasIndices -- typescript does not. May 24, 2021
@DanielRosenwasser DanielRosenwasser added the ES Next New featurers for ECMAScript (a.k.a. ESNext) label May 24, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.4.0 milestone May 24, 2021
@DanielRosenwasser DanielRosenwasser added Suggestion An idea for TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels May 24, 2021
@andrewbranch andrewbranch added the Rescheduled This issue was previously scheduled to an earlier milestone label Aug 30, 2021
@JoshuaWise
Copy link

I'm also needing this feature.

@nickserv
Copy link
Contributor

nickserv commented Dec 22, 2022

As a workaround, I've found these declarations helpful:

declare global {
  interface RegExpIndicesArray extends Array<[number, number]> {
    groups?: {
      [key: string]: [number, number]
    }

    0: [number, number]
  }

  interface RegExpMatchArray {
    indices?: RegExpIndicesArray
  }

  interface RegExpExecArray {
    indices?: RegExpIndicesArray
  }

  interface RegExp {
    readonly hasIndices: boolean
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript ES Next New featurers for ECMAScript (a.k.a. ESNext) Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants