-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(transformer/class-properties): fast path for instance prop initi…
…alizer scope re-parenting (#7901) Add a fast path for inserting instance property initializers into constructor, when no existing constructor or constructor has no bindings. This should be reasonably common. The `Scope flags mismatch` errors are due to #7900.
- Loading branch information
1 parent
feac02e
commit 80d0b3e
Showing
4 changed files
with
180 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...class-properties/test/fixtures/instance-prop-initializer-no-existing-constructor/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class C { | ||
function = function() {}; | ||
functions = [ | ||
function() { | ||
function foo() {} | ||
}, | ||
function() { | ||
function foo() {} | ||
} | ||
]; | ||
arrow = () => {}; | ||
arrows = [() => () => {}, () => () => {}]; | ||
klass = class {}; | ||
classExtends = class extends class {} {}; | ||
classes = [ | ||
class { | ||
method() { | ||
class D {} | ||
} | ||
method2() { | ||
class E {} | ||
} | ||
}, | ||
class { | ||
method() { | ||
class D {} | ||
} | ||
method2() { | ||
class E {} | ||
} | ||
} | ||
]; | ||
} |
29 changes: 29 additions & 0 deletions
29
...lass-properties/test/fixtures/instance-prop-initializer-no-existing-constructor/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class C { | ||
constructor() { | ||
babelHelpers.defineProperty(this, "function", function() {}); | ||
babelHelpers.defineProperty(this, "functions", [function() { | ||
function foo() {} | ||
}, function() { | ||
function foo() {} | ||
}]); | ||
babelHelpers.defineProperty(this, "arrow", () => {}); | ||
babelHelpers.defineProperty(this, "arrows", [() => () => {}, () => () => {}]); | ||
babelHelpers.defineProperty(this, "klass", class {}); | ||
babelHelpers.defineProperty(this, "classExtends", class extends class {} {}); | ||
babelHelpers.defineProperty(this, "classes", [class { | ||
method() { | ||
class D {} | ||
} | ||
method2() { | ||
class E {} | ||
} | ||
}, class { | ||
method() { | ||
class D {} | ||
} | ||
method2() { | ||
class E {} | ||
} | ||
}]); | ||
} | ||
} |