mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Fixes to emit / format for codeFix (#18484)
This commit is contained in:
@@ -2417,6 +2417,12 @@ namespace ts {
|
||||
|
||||
const isEmpty = isUndefined || start >= children.length || count === 0;
|
||||
if (isEmpty && format & ListFormat.OptionalIfEmpty) {
|
||||
if (onBeforeEmitNodeArray) {
|
||||
onBeforeEmitNodeArray(children);
|
||||
}
|
||||
if (onAfterEmitNodeArray) {
|
||||
onAfterEmitNodeArray(children);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3500,7 +3500,7 @@ ${code}
|
||||
expected = makeWhitespaceVisible(expected);
|
||||
actual = makeWhitespaceVisible(actual);
|
||||
}
|
||||
return `Expected:\n${expected}\nActual:${actual}`;
|
||||
return `Expected:\n${expected}\nActual:\n${actual}`;
|
||||
}
|
||||
|
||||
function differOnlyByWhitespace(a: string, b: string) {
|
||||
|
||||
@@ -755,9 +755,8 @@ namespace ts.formatting {
|
||||
return true;
|
||||
case SyntaxKind.Block: {
|
||||
const blockParent = context.currentTokenParent.parent;
|
||||
if (blockParent.kind !== SyntaxKind.ArrowFunction &&
|
||||
blockParent.kind !== SyntaxKind.FunctionExpression
|
||||
) {
|
||||
// In a codefix scenario, we can't rely on parents being set. So just always return true.
|
||||
if (!blockParent || blockParent.kind !== SyntaxKind.ArrowFunction && blockParent.kind !== SyntaxKind.FunctionExpression) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user