diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4027539334e..fc08a862007 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2267,8 +2267,8 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript; } - // If the parameter's name is 'this, then it is TypeScript syntax. - if ((node.name as Identifier).text === "this") { + // If the parameter's name is 'this', then it is TypeScript syntax. + if (node.name && (node.name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword) { transformFlags |= TransformFlags.AssertTypeScript; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 0f96c65a738..f930b7bc93a 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2115,12 +2115,12 @@ namespace ts { * This function will be called when one of the following conditions are met: * - The node has an accessibility modifier. * - The node has a questionToken. - * - The node's text is "this". + * - The node's kind is ThisKeyword. * * @param node The parameter declaration node. */ function visitParameter(node: ParameterDeclaration) { - if ((node.name as Identifier).text === "this") { + if (node.name && (node.name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword) { return undefined; } const clone = getMutableClone(node); diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index ccec3c563e8..cfe1706ae99 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -243,8 +243,7 @@ function implicitThis(n) { var impl = { a: 12, explicitVoid2: function () { return _this.a; }, - explicitVoid1: // ok, this: any because it refers to some outer object (window?) - function () { return 12; }, + explicitVoid1: function () { return 12; }, explicitStructural: function () { return this.a; },