Skip to content
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

Incompatible types with TypeScript 4.9 #140

Closed
JamieMagee opened this issue Nov 16, 2022 · 2 comments
Closed

Incompatible types with TypeScript 4.9 #140

JamieMagee opened this issue Nov 16, 2022 · 2 comments

Comments

@JamieMagee
Copy link
Contributor

After upgrading to TypeScript 4.9 I get the following errors from the TypeScript compiler:

Error: lib/expose.cjs(14,3): error TS2322: Type 'RE2Constructor' is not assignable to type 'RegExpConstructor'
Error: node_modules/re2/re2.d.ts(13,13): error TS2430: Interface 'RE2' incorrectly extends interface 'RegExp'.
  The types returned by 'exec(...)' are incompatible between these types.
    Type 'RE2ExecArray<string> | null' is not assignable to type 'RegExpExecArray | null'.
      Property '0' is missing in type 'RE2ExecArray<string>' but required in type 'RegExpExecArray'.
Error: node_modules/re2/re2.d.ts(28,13): error TS2430: Interface 'RE2Constructor' incorrectly extends interface 'RegExpConstructor'.
  The types returned by 'prototype.exec(...)' are incompatible between these types.
    Type 'RE2ExecArray<string> | null' is not assignable to type 'RegExpExecArray | null'.

You can find the full build output here.

The TypeScript 4.9 changelog includes Correctness Fixes and Breaking Changes lib.d.ts Updates, which is where I assume why the error has started occurring. I haven't yet narrowed down the fix.

@JamieMagee
Copy link
Contributor Author

It looks like 0 is now a required property for RegExpMatchArray and RegExpExecArray:

https://github.com/microsoft/TypeScript/blob/93bd577458d55cd720b2677705feab5c91eb12ce/src/lib/es5.d.ts#L920-L948

Changed in these PRs:

Adding the 0 property to RE2MatchArray and RE2ExecArray should resolve the issue, but I haven't verified this.

JamieMagee added a commit to JamieMagee/node-re2 that referenced this issue Nov 16, 2022
@uhop
Copy link
Owner

uhop commented Nov 23, 2022

Moved to #142.

@uhop uhop closed this as completed Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants