Fixes to emit / format for codeFix (#18486)

This commit is contained in:
Andy
2017-09-14 14:57:03 -07:00
committed by Mohamed Hegazy
parent b62d5f6696
commit 9639b52fcd
5 changed files with 56 additions and 5 deletions
+6
View File
@@ -2417,6 +2417,12 @@ namespace ts {
const isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0;
if (isEmpty && format & ListFormat.OptionalIfEmpty) {
if (onBeforeEmitNodeArray) {
onBeforeEmitNodeArray(children);
}
if (onAfterEmitNodeArray) {
onAfterEmitNodeArray(children);
}
return;
}
+2 -3
View File
@@ -757,9 +757,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;
}
}