Skip to content

Commit

Permalink
Complement #726 - JSDocParameterTag case.
Browse files Browse the repository at this point in the history
New JSDoc API of TypeScript 5.1 is so difficult than expected.  Maybe there will be a few more patches after that.
  • Loading branch information
samchon committed Jul 29, 2023
1 parent 1f71062 commit 4d845ea
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "4.1.10",
"version": "4.1.11",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "4.1.10",
"version": "4.1.11",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "4.1.10"
"typia": "4.1.11"
},
"peerDependencies": {
"typescript": ">= 4.7.4"
Expand Down
9 changes: 6 additions & 3 deletions src/factories/CommentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ export namespace CommentFactory {
}

const parseJSDocTag = (tag: ts.JSDocTag): string => {
const name: string | undefined = (
tag as ts.JSDocParameterTag
).name?.getText();
const parsed: string | undefined = ts.getTextOfJSDocComment(tag.comment);
return parsed?.length
? `@${tag.tagName.text} ${parsed}`
: `@${tag.tagName.text}`;
return [`@${tag.tagName.text}`, name, parsed]
.filter((str) => !!str?.length)
.join(" ");
};
19 changes: 19 additions & 0 deletions test/issues/comment-function.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import typia from "typia";

export interface IWrapper {
/**
* Compute two variables.
*
* @param x The first value
* @param y The second value
* @returns The result of computation
*/
compute: (x: number, y: number) => number;
}

const article = typia.metadata<[IWrapper]>().collection.objects[0];

console.log(
article.properties.find((p) => p.key.constants[0]?.values[0] === "compute")
?.description,
);

0 comments on commit 4d845ea

Please sign in to comment.