Fix ReferenceError in the wrapNativeSuper helper (#8100)
Fix a ReferenceError caused by a typo (`_construct` instead of `construct`) in the external `wrapNativeSuper` helper. (The typo doesn't usually cause an error in inline helpers because `_construct` happens to be the default name given to the `construct` helper function.)
This commit is contained in:
committed by
Nicolò Ribaudo
parent
b8dcd6f593
commit
2abd7839e1
@@ -2,7 +2,7 @@ var env = {
|
||||
Array: null,
|
||||
};
|
||||
|
||||
// Wee need to use "with" to avoid leaking the modified Array to other tests.
|
||||
// We need to use "with" to avoid leaking the modified Array to other tests.
|
||||
with (env) {
|
||||
class List extends Array {}
|
||||
expect(List.prototype.__proto__).toBeUndefined();
|
||||
|
||||
@@ -6,7 +6,7 @@ var env = {
|
||||
}
|
||||
};
|
||||
|
||||
// Wee need to use "with" to avoid leaking the modified Array to other tests.
|
||||
// We need to use "with" to avoid leaking the modified Array to other tests.
|
||||
with (env) {
|
||||
class List extends Array {};
|
||||
new List();
|
||||
|
||||
25
packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/wrap-native-super/exec.js
vendored
Normal file
25
packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/wrap-native-super/exec.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// basic sanity check to confirm the external wrapNativeSuper helper works
|
||||
|
||||
class Test1 extends Array {
|
||||
name() {
|
||||
return 'test1';
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends Array {
|
||||
name() {
|
||||
return 'test2';
|
||||
}
|
||||
}
|
||||
|
||||
var t1 = new Test1();
|
||||
var t2 = new Test2();
|
||||
|
||||
expect(Test1).not.toBe(Test2);
|
||||
expect(t1).not.toBe(t2);
|
||||
expect(t1.name()).toBe('test1');
|
||||
expect(t2.name()).toBe('test2');
|
||||
expect(t1).toBeInstanceOf(Test1);
|
||||
expect(t2).toBeInstanceOf(Test2);
|
||||
expect(t1).toBeInstanceOf(Array);
|
||||
expect(t2).toBeInstanceOf(Array);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-classes","transform-block-scoping","external-helpers"]
|
||||
}
|
||||
Reference in New Issue
Block a user