mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 14:34:35 -06:00
Merge pull request #10189 from chancancode/constructor-splat-arguments
Emit more efficient/concise "empty" ES6 ctor
This commit is contained in:
commit
9cc8b2ebb2
@ -5311,18 +5311,7 @@ const _super = (function (geti, seti) {
|
||||
emitSignatureParameters(ctor);
|
||||
}
|
||||
else {
|
||||
// Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation.
|
||||
// If constructor is empty, then,
|
||||
// If ClassHeritageopt is present, then
|
||||
// Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition.
|
||||
// Else,
|
||||
// Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition
|
||||
if (baseTypeElement) {
|
||||
write("(...args)");
|
||||
}
|
||||
else {
|
||||
write("()");
|
||||
}
|
||||
write("()");
|
||||
}
|
||||
}
|
||||
|
||||
@ -5360,7 +5349,7 @@ const _super = (function (geti, seti) {
|
||||
write("_super.apply(this, arguments);");
|
||||
}
|
||||
else {
|
||||
write("super(...args);");
|
||||
write("super(...arguments);");
|
||||
}
|
||||
emitEnd(baseTypeElement);
|
||||
}
|
||||
|
||||
@ -13,14 +13,14 @@ let C = class extends class extends class {
|
||||
}
|
||||
}
|
||||
{
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.b = 2;
|
||||
}
|
||||
}
|
||||
{
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.c = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ class D {
|
||||
}
|
||||
}
|
||||
class E extends D {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.z = true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user