Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node InferType did not pass test 'isEntityName' #509

Open
marcus-sa opened this issue Nov 16, 2023 · 9 comments · May be fixed by #561
Open

Node InferType did not pass test 'isEntityName' #509

marcus-sa opened this issue Nov 16, 2023 · 9 comments · May be fixed by #561

Comments

@marcus-sa
Copy link
Contributor

marcus-sa commented Nov 16, 2023

The original issue was marked as complete even though it wasn't fixed.

Reproduction

function a<T>(t: T): T {
    return b<T>(t);
}

function b<T>(t: T): T {
    return t;
}

a(1);

Workaround

Disable reflection for the specific scope

/** @reflection never */
@marcus-sa
Copy link
Contributor Author

marcus-sa commented Nov 16, 2023

@marcj I assume it's because of a change in TypeScript. I'm using 5.2.2 here.

@marcus-sa
Copy link
Contributor Author

marcus-sa commented Nov 16, 2023

In my PR for adding Nx to the repository, I had also upgraded the TypeScript version to 5.2.2, and the same error occurred.

@marcj
Copy link
Member

marcj commented Nov 16, 2023

I don't know. The old PR and your patch doesn't fix it, it basically disables the whole sextion since found is then always false, iirc. need to look into it closer to figure out a solution

@marcus-sa
Copy link
Contributor Author

@marcj I'm gonna have a look at it

@marcus-sa
Copy link
Contributor Author

@timvandam did you also have this issue with TypeScript 5.2.2 or was it a different version?

@timvandam
Copy link
Contributor

idk I forgot

@marcj
Copy link
Member

marcj commented Nov 21, 2023

FYI TypeScript 4.9.5 works fine with this code

marcj added a commit that referenced this issue Nov 21, 2023
@marcus-sa
Copy link
Contributor Author

marcus-sa commented Nov 21, 2023

@marcj the following patch to TypeScript fixes the issue for me

diff --git a/node_modules/typescript/lib/typescript.js b/node_modules/typescript/lib/typescript.js
index 86ab90b..dc72ecb 100644
--- a/node_modules/typescript/lib/typescript.js
+++ b/node_modules/typescript/lib/typescript.js
@@ -87586,7 +87586,7 @@ ${lanes.join("\n")}
         [183 /* TypeReference */]: function visitEachChildOfTypeReferenceNode(node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) {
           return context.factory.updateTypeReferenceNode(
             node,
-            Debug.checkDefined(nodeVisitor(node.typeName, visitor, isEntityName)),
+            Debug.checkDefined(nodeVisitor(node.typeName, visitor, node => isTypeNode(node) || isEntityName(node))),
             nodesVisitor(node.typeArguments, visitor, isTypeNode)
           );
         },

@marcus-sa
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants