Skip to content

Emit more efficient/concise "empty" ES6 ctor #10189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("()");
}
}

Expand Down Expand Up @@ -5360,7 +5349,7 @@ const _super = (function (geti, seti) {
write("_super.apply(this, arguments);");
}
else {
write("super(...args);");
write("super(...arguments);");
}
emitEnd(baseTypeElement);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/baselines/reference/classExpressionES63.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class D {
}
}
class E extends D {
constructor(...args) {
super(...args);
constructor() {
super(...arguments);
this.z = true;
}
}
Expand Down