Skip to content

Commit 4013379

Browse files
authored
1 parent 3c8c889 commit 4013379

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/tsStructureParser.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function parseStruct(content: string, modules: {[path: string]: Module},
102102
let isExport = false;
103103
let params: {name: string, type: string, mandatory: boolean}[] = [];
104104
if (name) {
105-
const modifierContainer = isArrow
105+
let modifierContainer = isArrow
106106
? (functionDeclaration.parent as ts.VariableDeclaration).initializer
107107
: functionDeclaration;
108108
if (modifierContainer && modifierContainer.modifiers) {
@@ -116,6 +116,20 @@ export function parseStruct(content: string, modules: {[path: string]: Module},
116116
});
117117
}
118118

119+
if (isArrow && !isExport) {
120+
do {
121+
modifierContainer = modifierContainer.parent as ts.Expression;
122+
} while (modifierContainer && modifierContainer.kind !== ts.SyntaxKind.VariableStatement);
123+
124+
if (modifierContainer && modifierContainer.modifiers) {
125+
modifierContainer.modifiers.forEach(modi => {
126+
if (modi.kind === ts.SyntaxKind.ExportKeyword) {
127+
isExport = true;
128+
}
129+
});
130+
}
131+
}
132+
119133
functionDeclaration.parameters.forEach(param => {
120134
params.push({
121135
name: param.name.getText(),

test/src/model/hero/testFunction.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
{
4747
"isArrow": true,
48-
"isExport": false,
48+
"isExport": true,
4949
"isAsync": false,
5050
"name": "arrowFunctionLikeVariable",
5151
"params": []
@@ -59,7 +59,7 @@
5959
},
6060
{
6161
"isArrow": true,
62-
"isExport": false,
62+
"isExport": true,
6363
"isAsync": true,
6464
"name": "arrowAsyncFunctionLikeVariable",
6565
"params": [ { "name": "params1", "type": "string", "mandatory": true } ]
@@ -74,7 +74,7 @@
7474
{
7575
"isArrow": true,
7676
"isAsync": true,
77-
"isExport": false,
77+
"isExport": true,
7878
"name": "analogIdsTransformer",
7979
"params": [
8080
{

0 commit comments

Comments
 (0)