deepkit-framework
deepkit-framework copied to clipboard
Node InferType did not pass test 'isEntityName'
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 */
@marcj I assume it's because of a change in TypeScript. I'm using 5.2.2 here.
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.
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 I'm gonna have a look at it
@timvandam did you also have this issue with TypeScript 5.2.2 or was it a different version?
idk I forgot
FYI TypeScript 4.9.5 works fine with this code
@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)
);
},
https://github.com/microsoft/TypeScript/issues/56480