Skip to content

Commit 6bc2a84

Browse files
committed
Avoid double iteration in preserveCommentsOn
1 parent 5919ec9 commit 6bc2a84

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7310,9 +7310,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
73107310
typeElements.push(preserveCommentsOn(propertySignature));
73117311

73127312
function preserveCommentsOn<T extends Node>(node: T) {
7313-
if (some(propertySymbol.declarations, d => d.kind === SyntaxKind.JSDocPropertyTag)) {
7314-
const d = propertySymbol.declarations?.find(d => d.kind === SyntaxKind.JSDocPropertyTag)! as JSDocPropertyTag;
7315-
const commentText = getTextOfJSDocComment(d.comment);
7313+
const jsdocPropertyTag = propertySymbol.declarations?.find((d): d is JSDocPropertyTag => d.kind === SyntaxKind.JSDocPropertyTag);
7314+
if (jsdocPropertyTag) {
7315+
const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment);
73167316
if (commentText) {
73177317
setSyntheticLeadingComments(node, [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
73187318
}

0 commit comments

Comments
 (0)