Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c55de35

Browse files
committed
Address PR comments
1. Test name.originalKeywordKind: SyntaxKind instead of name.text: string. 2. Revert regression in comment placement when emitting methods as function properties.
1 parent 9797c9c commit c55de35

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/compiler/binder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2267,8 +2267,8 @@ namespace ts {
22672267
transformFlags |= TransformFlags.AssertTypeScript;
22682268
}
22692269

2270-
// If the parameter's name is 'this, then it is TypeScript syntax.
2271-
if ((node.name as Identifier).text === "this") {
2270+
// If the parameter's name is 'this', then it is TypeScript syntax.
2271+
if (node.name && (node.name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword) {
22722272
transformFlags |= TransformFlags.AssertTypeScript;
22732273
}
22742274

src/compiler/transformers/ts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2115,12 +2115,12 @@ namespace ts {
21152115
* This function will be called when one of the following conditions are met:
21162116
* - The node has an accessibility modifier.
21172117
* - The node has a questionToken.
2118-
* - The node's text is "this".
2118+
* - The node's kind is ThisKeyword.
21192119
*
21202120
* @param node The parameter declaration node.
21212121
*/
21222122
function visitParameter(node: ParameterDeclaration) {
2123-
if ((node.name as Identifier).text === "this") {
2123+
if (node.name && (node.name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword) {
21242124
return undefined;
21252125
}
21262126
const clone = getMutableClone(node);

tests/baselines/reference/thisTypeInFunctions.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ function implicitThis(n) {
243243
var impl = {
244244
a: 12,
245245
explicitVoid2: function () { return _this.a; },
246-
explicitVoid1: // ok, this: any because it refers to some outer object (window?)
247-
function () { return 12; },
246+
explicitVoid1: function () { return 12; },
248247
explicitStructural: function () {
249248
return this.a;
250249
},

0 commit comments

Comments
 (0)