Skip to content

Commit

Permalink
Fix wrong logic when PropSync Model decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo930021 committed Aug 14, 2020
1 parent 9043eda commit 0142a37
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions server/src/modes/script/componentInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,24 @@ function getProps(tsModule: T_TypeScript, defaultExportType: ts.Type, checker: t
return undefined;
}

return propsSymbols.map(prop => {
return propsSymbols.map(propSymbol => {
const prop = propSymbol.valueDeclaration as ts.PropertyDeclaration;
const decoratorExpr = prop.decorators?.find(decorator =>
tsModule.isCallExpression(decorator.expression)
? propDecoratorNames.includes(decorator.expression.expression.getText())
: false
)?.expression as ts.CallExpression;
const decoratorName = decoratorExpr.expression.getText();
const args = decoratorExpr.arguments;

const firstNode = args[0];
if (decoratorName === 'PropSync' && tsModule.isStringLiteral(firstNode)) {
return { name: firstNode.text, documentation: buildDocumentation(tsModule, propSymbol, checker) };
}

return {
name: prop.name,
documentation: buildDocumentation(tsModule, prop, checker)
name: propSymbol.name,
documentation: buildDocumentation(tsModule, propSymbol, checker)
};
});
}
Expand Down

0 comments on commit 0142a37

Please sign in to comment.