-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
visitor of visitEachChild doesn't support returning InferTypeNode #56480
Comments
The following patch fixes it (or at least works around it): 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)
);
}, |
@andrewbranch where are we with this? I would gladly make a PR. |
A const searchArgument = (node: Node): Node => {
node = visitEachChild(node, searchArgument, this.context);
if (isTypeReferenceNode(node) && isIdentifier(node.typeName) && node.typeName.escapedText === argumentName) {
//transform to infer T
found = true;
node = this.f.createInferTypeNode(declaration);
}
return node;
}; |
@rbuckton thanks a lot! |
microsoft/TypeScript#56480 (comment) Signed-off-by: Marcus S. Abildskov <8391194+marcus-sa@users.noreply.github.com>
π Search Terms
False expression: Unexpected node
Node InferType did not pass test 'isEntityName'.
π Version & Regression Information
β― Playground Link
No response
π» Code
https://github.com/marcus-sa/deepkit-framework/blob/9c9eb001459a4e1046aea94cb531ba5d8ca3b1c9/packages/type-compiler/src/compiler.ts#L2353-L2370
π Actual behavior
Visitor callback of visitEachChild doesn't support returning InferTypeNode when the node is a TypeReferenceNode
π Expected behavior
For it to work
The text was updated successfully, but these errors were encountered: