Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(store): property name parsing js-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReincarnator committed Dec 12, 2017
1 parent 3eaac4a commit 182cdcf
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/store/pattern/parser/typescript_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ export class TypeScriptParser extends PatternParser {
});
}

protected getJsDocValue(node: ts.Node, tagName: string): string | undefined {
const jsDocTags: ReadonlyArray<ts.JSDocTag> | undefined = ts.getJSDocTags(node);
let result: string | undefined;
if (jsDocTags) {
jsDocTags.forEach(jsDocTag => {
if (jsDocTag.tagName && jsDocTag.tagName.text === tagName) {
result = jsDocTag.comment;
}
});
}

return result;
}

protected getPropsTypeName(): string {
return `${this.typeName}Props`;
}
Expand Down Expand Up @@ -99,8 +113,10 @@ export class TypeScriptParser extends PatternParser {
const required: boolean = signature.questionToken === undefined;

const id: string = signature.name.getText();
// TODO: Replace by actual name
const name: string = id;
let name: string | undefined = this.getJsDocValue(signature, 'name');
if (name === undefined) {
name = id;
}

const typeNode: ts.TypeNode | undefined = signature.type;
if (!typeNode) {
Expand Down

0 comments on commit 182cdcf

Please sign in to comment.