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

Skip to content

Commit d42ecff

Browse files
committed
apply armano's suggested node type change
1 parent b9f12b9 commit d42ecff

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/typescript-estree/src/convert.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -801,12 +801,11 @@ export class Converter {
801801

802802
case SyntaxKind.Identifier: {
803803
if (isThisInTypeQuery(node)) {
804-
return this.createNode<TSESTree.ThisExpression>(
805-
node as unknown as ts.ThisExpression,
806-
{
807-
type: AST_NODE_TYPES.ThisExpression,
808-
},
809-
);
804+
// special case for `typeof this.foo` - TS emits an Identifier for `this`
805+
// but we want to treat it as a ThisExpression for consistency
806+
return this.createNode<TSESTree.ThisExpression>(node, {
807+
type: AST_NODE_TYPES.ThisExpression,
808+
});
810809
}
811810
return this.createNode<TSESTree.Identifier>(node, {
812811
type: AST_NODE_TYPES.Identifier,

packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ export interface EstreeToTsNodeTypes {
149149
[AST_NODE_TYPES.TemplateLiteral]:
150150
| ts.NoSubstitutionTemplateLiteral
151151
| ts.TemplateExpression;
152-
[AST_NODE_TYPES.ThisExpression]: ts.ThisExpression | ts.KeywordTypeNode;
152+
[AST_NODE_TYPES.ThisExpression]:
153+
| ts.ThisExpression
154+
| ts.KeywordTypeNode
155+
| ts.Identifier;
153156
[AST_NODE_TYPES.ThrowStatement]: ts.ThrowStatement;
154157
[AST_NODE_TYPES.TryStatement]: ts.TryStatement;
155158
[AST_NODE_TYPES.TSAbstractPropertyDefinition]: ts.PropertyDeclaration;

0 commit comments

Comments
 (0)