After using babel,class inheritance, the new.target of the parent class is equal to undefined. Is there a solution?

problem description

after using babel,class inheritance, the new.target of the parent class is equal to undefined. Is there a solution?

the environmental background of the problems and what methods you have tried

https://github.com/babel/babe...

related codes

var A = class A {
  constructor() {
    console.log(new.target, "a");
  }
}

var B = class B extends A {
  constructor() {
    super();
    console.log(new.target, "b");
  }
}

var obj = new B("b"); //  false

running directly on node returns

[Function: B] "a"
[Function: B] "b"

but if babel is used, it returns

undefined "a"
[Function: B] "b"
Jun.22,2022

because after babel translation, super () in subclass B is replaced by A.constructor.call () , so new.target is of course undefined


cannot be solved. Not all features can be compiled consistent with the new version. You have to find a way around


to temporarily replace new.target with this.constructor.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2be8a-2baeb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2be8a-2baeb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?