deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

Node InferType did not pass test 'isEntityName'

Open marcus-sa opened this issue 1 year ago • 16 comments

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 avatar Nov 16 '23 21:11 marcus-sa

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

marcus-sa avatar Nov 16 '23 21:11 marcus-sa

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.

marcus-sa avatar Nov 16 '23 21:11 marcus-sa

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

marcj avatar Nov 16 '23 21:11 marcj

@marcj I'm gonna have a look at it

marcus-sa avatar Nov 16 '23 21:11 marcus-sa

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

marcus-sa avatar Nov 17 '23 15:11 marcus-sa

idk I forgot

timvandam avatar Nov 17 '23 16:11 timvandam

FYI TypeScript 4.9.5 works fine with this code

marcj avatar Nov 21 '23 11:11 marcj

@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 avatar Nov 21 '23 12:11 marcus-sa

https://github.com/microsoft/TypeScript/issues/56480

marcus-sa avatar Nov 28 '23 09:11 marcus-sa