Skip to content

Commit 5b1b93b

Browse files
angrychowclaude
andauthored
fix: use variable symbol instead of arrow function symbol for default… (#118)
* 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> * upd version --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ab6d6b7 commit 5b1b93b

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

ts-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "abcoder-ts-parser",
3-
"version": "0.0.9",
3+
"version": "0.0.13",
44
"description": "TypeScript AST parser for UNIAST specification",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

ts-parser/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const program = new Command();
1111
program
1212
.name('abcoder-ts-parser')
1313
.description('TypeScript AST parser for UNIAST specification')
14-
.version('0.0.9');
14+
.version('0.0.13');
1515

1616
program
1717
.command('parse')

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)