Skip to content

Commit

Permalink
fix: cannot resolve template context properties in type reference
Browse files Browse the repository at this point in the history
close #1422
  • Loading branch information
johnsoncodehk committed Jun 12, 2022
1 parent ab5821b commit 420d1f2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/vue-code-gen/src/transform.ts
Expand Up @@ -142,7 +142,8 @@ function walkIdentifiers(
}
}
else if (ts.isTypeReferenceNode(node)) {
// ignore
// fix https://github.com/johnsoncodehk/volar/issues/1422
node.forEachChild(node => walkIdentifiersInTypeReference(ts, node, cb));
}
else {
node.forEachChild(node => walkIdentifiers(ts, node, cb, localVars));
Expand All @@ -152,6 +153,19 @@ function walkIdentifiers(
localVars[varName]--;
}

function walkIdentifiersInTypeReference(
ts: typeof import('typescript/lib/tsserverlibrary'),
node: ts.Node,
cb: (varNode: ts.Identifier, isShorthand: boolean) => void,
) {
if (ts.isTypeQueryNode(node) && ts.isIdentifier(node.exprName)) {
cb(node.exprName, false);
}
else {
node.forEachChild(node => walkIdentifiersInTypeReference(ts, node, cb));
}
}

export function colletVars(
ts: typeof import('typescript/lib/tsserverlibrary'),
node: ts.Node,
Expand Down

0 comments on commit 420d1f2

Please sign in to comment.