Hermes: bug(chore): String.prototype.matchAll is undefined

Created on 6 Oct 2020  路  3Comments  路  Source: facebook/hermes

String.prototype.matchAll is undefined

  • [x] I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: [email protected]
React Native version (if any): 0.63.2
Android version (if any): 10.0+ (API 30)
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86

Steps To Reproduce

  1. console.log(String.prototype.matchAll) // undefined
const result = [..."aaa".matchAll(/A/g)];

Throws:
Undefined is not a function

The Expected Behavior

I would expect String.prototype.matchAll to exist

Most helpful comment

@tmikov @Gregoirevda

Actually, Hermes had already implemented ES2020 String.prototype.matchAll and ES2021 String.prototype.replaceAll natively and they are included in Release v0.6.0.

Once the RN 0.64 is out, you can upgrade to Hermes v0.6 or v0.7 to use them natively ;)
As for RN 0.63, feel free to use the polyfill that Jordan suggested.

All 3 comments

In the meantime, you can use https://npmjs.com/string.prototype.matchall.

@Gregoirevda String.prototype.matchAll() was added in ES2020. We are gradually implementing features of newer spec versions, but we haven't fully caught up to ES2020 yet :-) So, we will get to it, but not sure when, especially if quality polyfills already exist.

@tmikov @Gregoirevda

Actually, Hermes had already implemented ES2020 String.prototype.matchAll and ES2021 String.prototype.replaceAll natively and they are included in Release v0.6.0.

Once the RN 0.64 is out, you can upgrade to Hermes v0.6 or v0.7 to use them natively ;)
As for RN 0.63, feel free to use the polyfill that Jordan suggested.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaodeng picture gaodeng  路  4Comments

benjamingr picture benjamingr  路  6Comments

ghost picture ghost  路  5Comments

viky293 picture viky293  路  4Comments

NWU-NISL picture NWU-NISL  路  4Comments