From 5768b42bfaddceeb1d5258a188eeac11f78dc16b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Jul 2016 11:42:59 -0700 Subject: [PATCH] Skip `this` in emitter in 2 more places --- src/compiler/emitter.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7ac3b5acfb0..737edd425f6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4571,14 +4571,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function emitRestParameter(node: FunctionLikeDeclaration) { if (languageVersion < ScriptTarget.ES6 && hasDeclaredRestParameter(node)) { - const restIndex = node.parameters.length - 1; - const restParam = node.parameters[restIndex]; + const restParam = node.parameters[node.parameters.length - 1]; // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. if (isBindingPattern(restParam.name)) { return; } + const skipThisCount = node.parameters.length && (node.parameters[0].name).text === "this" ? 1 : 0; + const restIndex = node.parameters.length - 1 - skipThisCount; const tempName = createTempVariable(TempFlags._i).text; writeLine(); emitLeadingComments(restParam); @@ -6156,10 +6157,11 @@ const _super = (function (geti, seti) { if (valueDeclaration) { const parameters = valueDeclaration.parameters; + const skipThisCount = parameters.length && (parameters[0].name).text === "this" ? 1 : 0; const parameterCount = parameters.length; - if (parameterCount > 0) { - for (let i = 0; i < parameterCount; i++) { - if (i > 0) { + if (parameterCount > skipThisCount) { + for (let i = skipThisCount; i < parameterCount; i++) { + if (i > skipThisCount) { write(", "); }