* Extracts the method definition from a method declaration.
(
member: ts.MethodDeclaration,
)
| 285 | * Extracts the method definition from a method declaration. |
| 286 | */ |
| 287 | private extractMethodDefinition( |
| 288 | member: ts.MethodDeclaration, |
| 289 | ): MethodDefinition { |
| 290 | const functionComments = Comments.getTsDocCommentsForFunction( |
| 291 | member, |
| 292 | this.sourceFile, |
| 293 | ); |
| 294 | const name = ts.isConstructorDeclaration(member) |
| 295 | ? "constructor" |
| 296 | : member.name.getText(); |
| 297 | let signature = |
| 298 | name + |
| 299 | "(" + |
| 300 | member.parameters.map((param) => param.getText()).join(", ") + |
| 301 | ")"; |
| 302 | signature = signature.replace(/</g, "<").replace(/>/g, ">"); |
| 303 | return { |
| 304 | signature, |
| 305 | comment: functionComments.comment, |
| 306 | parameters: member.parameters.map((param) => { |
| 307 | return { |
| 308 | name: param.name.getText(), |
| 309 | type: param.type?.getText() || "unknown", |
| 310 | required: !param.questionToken, |
| 311 | comment: functionComments.params[param.name.getText()] || "", |
| 312 | }; |
| 313 | }), |
| 314 | }; |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Get the constructor definition of a class. |
no test coverage detected