(
node: ts.Node,
sourceFile: ts.SourceFile,
)
| 2 | |
| 3 | export class Comments { |
| 4 | static getCleanedCommentsForNode( |
| 5 | node: ts.Node, |
| 6 | sourceFile: ts.SourceFile, |
| 7 | ): string { |
| 8 | const fullText = sourceFile.getFullText(); |
| 9 | const commentRanges = ts.getLeadingCommentRanges( |
| 10 | fullText, |
| 11 | node.getFullStart(), |
| 12 | ); |
| 13 | |
| 14 | if (!commentRanges) return ""; |
| 15 | |
| 16 | return commentRanges |
| 17 | .map((comment) => { |
| 18 | let commentText = fullText.substring(comment.pos, comment.end); |
| 19 | commentText = Comments.removeCommentSyntax(commentText); |
| 20 | |
| 21 | // for now, remove @default annotations |
| 22 | commentText = commentText |
| 23 | .split("\n") |
| 24 | .filter((line) => !line.includes("@default")) |
| 25 | .join("\n"); |
| 26 | |
| 27 | return commentText; |
| 28 | }) |
| 29 | .join("\n") |
| 30 | .trim(); |
| 31 | } |
| 32 | |
| 33 | static getDefaultValueForNode( |
| 34 | node: ts.Node, |
no test coverage detected