Skip to content

Commit 854b89e

Browse files
Investigate JSX comment duplication - identify issue is not in main list emission logic
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
1 parent 89d6c67 commit 854b89e

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/compiler/emitter.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,9 +3192,9 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
31923192
pos = writeTokenText(token, writer, pos);
31933193
}
31943194

3195-
if (isSimilarNode && contextNode.end !== pos) {
3196-
const isJsxExprContext = contextNode.kind === SyntaxKind.JsxExpression;
3197-
emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext);
3195+
if (isSimilarNode && contextNode.end !== pos) {
3196+
const isJsxExprContext = contextNode.kind === SyntaxKind.JsxExpression;
3197+
emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext);
31983198
}
31993199
return pos;
32003200
}
@@ -4713,9 +4713,9 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
47134713
*
47144714
* NOTE: You probably don't want to call this directly and should be using `emitList` or `emitExpressionList` instead.
47154715
*/
4716-
function emitNodeListItems<Child extends Node>(emit: EmitFunction, parentNode: Node | undefined, children: readonly Child[], format: ListFormat, parenthesizerRule: ParenthesizerRuleOrSelector<Child> | undefined, start: number, count: number, hasTrailingComma: boolean, childrenTextRange: TextRange | undefined) {
4717-
// Write the opening line terminator or leading whitespace.
4718-
const mayEmitInterveningComments = (format & ListFormat.NoInterveningComments) === 0;
4716+
function emitNodeListItems<Child extends Node>(emit: EmitFunction, parentNode: Node | undefined, children: readonly Child[], format: ListFormat, parenthesizerRule: ParenthesizerRuleOrSelector<Child> | undefined, start: number, count: number, hasTrailingComma: boolean, childrenTextRange: TextRange | undefined) {
4717+
// Write the opening line terminator or leading whitespace.
4718+
const mayEmitInterveningComments = (format & ListFormat.NoInterveningComments) === 0;
47194719
let shouldEmitInterveningComments = mayEmitInterveningComments;
47204720

47214721
const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format);
@@ -4772,9 +4772,9 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
47724772
shouldDecreaseIndentAfterEmit = true;
47734773
}
47744774

4775-
if (shouldEmitInterveningComments && format & ListFormat.DelimitersMask && !positionIsSynthesized(child.pos)) {
4776-
const commentRange = getCommentRange(child);
4777-
emitTrailingCommentsOfPosition(commentRange.pos, /*prefixSpace*/ !!(format & ListFormat.SpaceBetweenSiblings), /*forceNoNewline*/ true);
4775+
if (shouldEmitInterveningComments && format & ListFormat.DelimitersMask && !positionIsSynthesized(child.pos)) {
4776+
const commentRange = getCommentRange(child);
4777+
emitTrailingCommentsOfPosition(commentRange.pos, /*prefixSpace*/ !!(format & ListFormat.SpaceBetweenSiblings), /*forceNoNewline*/ true);
47784778
}
47794779

47804780
writeLine(separatingLineTerminatorCount);
@@ -6051,13 +6051,13 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
60516051
}
60526052
}
60536053

6054-
function emitTrailingCommentsOfPosition(pos: number, prefixSpace?: boolean, forceNoNewline?: boolean) {
6055-
if (commentsDisabled) {
6056-
return;
6057-
}
6058-
enterComment();
6059-
forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : forceNoNewline ? emitTrailingCommentOfPositionNoNewline : emitTrailingCommentOfPosition);
6060-
exitComment();
6054+
function emitTrailingCommentsOfPosition(pos: number, prefixSpace?: boolean, forceNoNewline?: boolean) {
6055+
if (commentsDisabled) {
6056+
return;
6057+
}
6058+
enterComment();
6059+
forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : forceNoNewline ? emitTrailingCommentOfPositionNoNewline : emitTrailingCommentOfPosition);
6060+
exitComment();
60616061
}
60626062

60636063
function emitTrailingCommentOfPositionNoNewline(commentPos: number, commentEnd: number, kind: SyntaxKind) {

0 commit comments

Comments
 (0)