Skip to content

Commit

Permalink
fix(typescript-estree): correct tsNodeToESTreeNodeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Feb 25, 2021
1 parent 63a0f6f commit 279bc8e
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions packages/typescript-estree/src/convert.ts
Expand Up @@ -517,15 +517,10 @@ export class Converter {
return result;
}

private convertJSXIdentifier(
node: ts.Identifier,
name?: string,
range?: [number, number],
): TSESTree.JSXIdentifier {
private convertJSXIdentifier(node: ts.Identifier): TSESTree.JSXIdentifier {
const result = this.createNode<TSESTree.JSXIdentifier>(node, {
type: AST_NODE_TYPES.JSXIdentifier,
name: name ?? node.text,
range,
name: node.text,
});
this.registerTSNodeInNodeMap(node, result);
return result;
Expand All @@ -540,15 +535,16 @@ export class Converter {
const range = getRange(node, this.ast);
const result = this.createNode<TSESTree.JSXNamespacedName>(node, {
type: AST_NODE_TYPES.JSXNamespacedName,
namespace: this.convertJSXIdentifier(
node,
node.text.slice(0, colonIndex),
[range[0], range[0] + colonIndex],
),
name: this.convertJSXIdentifier(node, node.text.slice(colonIndex + 1), [
range[0] + colonIndex + 1,
range[1],
]),
namespace: this.createNode<TSESTree.JSXIdentifier>(node, {
type: AST_NODE_TYPES.JSXIdentifier,
name: node.text.slice(0, colonIndex),
range: [range[0], range[0] + colonIndex],
}),
name: this.createNode<TSESTree.JSXIdentifier>(node, {
type: AST_NODE_TYPES.JSXIdentifier,
name: node.text.slice(colonIndex + 1),
range: [range[0] + colonIndex + 1, range[1]],
}),
range,
});
this.registerTSNodeInNodeMap(node, result);
Expand Down Expand Up @@ -2728,7 +2724,7 @@ export class Converter {
? (node as any).elementTypes.map((el: ts.Node) =>
this.convertType(el),
)
: node.elements.map((el: ts.Node) => this.convertType(el));
: node.elements.map(el => this.convertType(el));

return this.createNode<TSESTree.TSTupleType>(node, {
type: AST_NODE_TYPES.TSTupleType,
Expand Down

0 comments on commit 279bc8e

Please sign in to comment.