Skip to content

Bug: Something is wrong in Converter#convertTypeArgumentsToTypeParameterInstantiation() #11245

Closed as not planned
@fisker

Description

@fisker

Sorry for ignoring the issue template.

There is an issue in Prettier prettier/prettier#15463.

This issue now fixed in typescript-estree v8, but when I look into it, I found there is something wrong, I haven't found out the root cause yet.

Running this script will succeed

const code = `
type RepeatedTuple<T extends readonly any[]> =
    _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T,
        _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T,
            _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T, _R<T,
                _R<T, _R<T, _R<T, _R<T, readonly []>>>>>
            >>>>>>>>>>>>>>>>>>>
        >>>>>>>>>>>>>
    >>>;
`;

console.log(
  require("@typescript-eslint/typescript-estree").parse(code)
);

However, if I call convertTypeArgumentsToTypeParameterInstantiation twice in this branch

case SyntaxKind.TypeReference:
return this.createNode<TSESTree.TSTypeReference>(node, {
type: AST_NODE_TYPES.TSTypeReference,
typeArguments:
node.typeArguments &&
this.convertTypeArgumentsToTypeParameterInstantiation(
node.typeArguments,
node,
),
typeName: this.convertChild(node.typeName),
});

for example:

      case SyntaxKind.TypeReference:
        return this.createNode<TSESTree.TSTypeReference>(node, {
          type: AST_NODE_TYPES.TSTypeReference,
          typeArguments:
            node.typeArguments &&
            this.convertTypeArgumentsToTypeParameterInstantiation(
              node.typeArguments,
              node,
            ),
+          typeArguments2:
+            node.typeArguments &&
+            this.convertTypeArgumentsToTypeParameterInstantiation(
+              node.typeArguments,
+              node,
+            ),
          typeName: this.convertChild(node.typeName),
        });

The parser hangs forever.

I don't think this is expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseIssues waiting for a reply from the OP or another partybugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions