Skip to content

Commit 5efbf61

Browse files
committed
Skip this in emitter in 2 more places
1 parent f9d2937 commit 5efbf61

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/compiler/emitter.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4571,14 +4571,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
45714571

45724572
function emitRestParameter(node: FunctionLikeDeclaration) {
45734573
if (languageVersion < ScriptTarget.ES6 && hasDeclaredRestParameter(node)) {
4574-
const restIndex = node.parameters.length - 1;
4575-
const restParam = node.parameters[restIndex];
4574+
const restParam = node.parameters[node.parameters.length - 1];
45764575

45774576
// A rest parameter cannot have a binding pattern, so let's just ignore it if it does.
45784577
if (isBindingPattern(restParam.name)) {
45794578
return;
45804579
}
45814580

4581+
const skipThisCount = node.parameters.length && (<Identifier>node.parameters[0].name).text === "this" ? 1 : 0;
4582+
const restIndex = node.parameters.length - 1 - skipThisCount;
45824583
const tempName = createTempVariable(TempFlags._i).text;
45834584
writeLine();
45844585
emitLeadingComments(restParam);
@@ -6155,10 +6156,11 @@ const _super = (function (geti, seti) {
61556156

61566157
if (valueDeclaration) {
61576158
const parameters = valueDeclaration.parameters;
6159+
const skipThisCount = parameters.length && (<Identifier>parameters[0].name).text === "this" ? 1 : 0;
61586160
const parameterCount = parameters.length;
6159-
if (parameterCount > 0) {
6160-
for (let i = 0; i < parameterCount; i++) {
6161-
if (i > 0) {
6161+
if (parameterCount > skipThisCount) {
6162+
for (let i = skipThisCount; i < parameterCount; i++) {
6163+
if (i > skipThisCount) {
61626164
write(", ");
61636165
}
61646166

0 commit comments

Comments
 (0)