| 352 | return []; |
| 353 | } |
| 354 | function getCommentForUnions(t: ts.TypeNode) { |
| 355 | const commentLines = t.getFullText().replace(t.getText(), '').split(/\r?\n/); |
| 356 | const comment = commentLines.map((line, index) => { |
| 357 | if (index === 0) { |
| 358 | line = line.trim().startsWith('/**') ? line.trim().replace('/**', '') : line; |
| 359 | } |
| 360 | if (commentLines.length === index + 1) { |
| 361 | // Last time, remove trailing `*/` |
| 362 | return line.trim().endsWith('*/') ? line.trim().replace('*/', '') : line; |
| 363 | } else { |
| 364 | return line.trim().startsWith('*') ? line.trim().replace('*', '') : line; // CodeQL [SM02383] Replace just the first occurrence of '*'. |
| 365 | } |
| 366 | }); |
| 367 | |
| 368 | // Remove leading empty lines. |
| 369 | while (comment.length > 0 && comment[0].trim().length === 0) { |
| 370 | comment.shift(); |
| 371 | } |
| 372 | |
| 373 | return comment.length === 0 ? undefined : comment; |
| 374 | } |
| 375 | |
| 376 | type EventProblem = { eventConstantName: string; problems: string[] }; |
| 377 | |