Skip to content

Support new.target #193

@charpeni

Description

@charpeni

Currently on master (e13f095), new.target is not supported.

It will be great to support it in Hermes as some third party dependencies are relying on this internally.

Using Hermes will result in those errors:

Case 1

class CustomError extends Error {
  constructor(message) {
    super(message); // 'Error' breaks prototype chain here
    Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
  }
}
error: ')' expected at end of function call
    Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
                         ~~~~~~~~~~~~~~~~~^

Case 2

class CustomError extends Error {
  constructor(message) {
    console.log(new.target);
  }
}
error: invalid statement encountered.
class CustomError extends Error {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Emitted 1 errors. exiting.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions