Skip to content

Commit 06fe03e

Browse files
committed
feat: only count function body vars
1 parent 1c6e70d commit 06fe03e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/emitter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,8 @@ export function emitFile(
17641764
|| (node.kind === ts.SyntaxKind.MethodDeclaration && !ts.isClassDeclaration(node.parent))
17651765
) {
17661766
const wrappedNode = createWrappedNode(node, {typeChecker});
1767-
const identifiers = wrappedNode.getDescendantsOfKind(ts.SyntaxKind.Identifier);
1767+
const body = wrappedNode.getBody();
1768+
const identifiers = body.getKind() === ts.SyntaxKind.Identifier ? [body as tsMorph.Identifier] : body.getDescendantsOfKind(ts.SyntaxKind.Identifier);
17681769
const inheritedVariables: tsMorph.Identifier[] = [];
17691770
const nodeStart = node.getStart();
17701771
const nodeEnd = node.getEnd();

test/features/inheritedVariables.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ let f = function () {
2121
}
2222

2323
let obj = {
24+
/**
25+
* aaa
26+
*
27+
* @ssr
28+
*/
2429
a: function () {
2530
return '123' + b;
2631
},

0 commit comments

Comments
 (0)