Skip to content

Commit 81509b0

Browse files
angrychowclaude
andcommitted
fix: use variable symbol instead of arrow function symbol for default export check
Fixed an issue where arrow function default export detection was checking the arrow function's symbol instead of the variable declaration's symbol. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ab6d6b7 commit 81509b0

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

ts-parser/src/parser/FunctionParser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ export class FunctionParser {
386386
isExported = true;
387387
} else {
388388
const parent = varDecl.getVariableStatement();
389-
isExported = parent ? (parent.isExported() || parent.isDefaultExport() || (this.defaultExportSymbol === arrowFunc.getSymbol() && this.defaultExportSymbol !== undefined)) : false;
389+
const varSymbol = varDecl.getSymbol();
390+
isExported = parent ? (parent.isExported() || parent.isDefaultExport() || (this.defaultExportSymbol === varSymbol && this.defaultExportSymbol !== undefined)) : false;
390391
}
391392

392393
return {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// 测试用例:箭头函数先声明,然后作为默认导出
2+
const foo = () => {
3+
console.log('bar')
4+
}
5+
6+
export default foo;
7+
8+
// 对比:直接导出的箭头函数
9+
export const bar = () => {
10+
console.log('baz')
11+
}

0 commit comments

Comments
 (0)