Fix formatter crash for const { ...a: b } = {};: forEachChild and emitBindingElement should handle ... before the propertyName (#21268)

This commit is contained in:
Andy
2018-01-18 10:36:41 -08:00
committed by GitHub
parent c11a3f4ff6
commit 9436b1cc0b
3 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -1268,12 +1268,12 @@ namespace ts {
}
function emitBindingElement(node: BindingElement) {
emitIfPresent(node.dotDotDotToken);
if (node.propertyName) {
emit(node.propertyName);
writePunctuation(":");
writeSpace();
}
emitIfPresent(node.dotDotDotToken);
emit(node.name);
emitInitializer(node.initializer);
}
+1 -1
View File
@@ -126,8 +126,8 @@ namespace ts {
case SyntaxKind.BindingElement:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<BindingElement>node).propertyName) ||
visitNode(cbNode, (<BindingElement>node).dotDotDotToken) ||
visitNode(cbNode, (<BindingElement>node).propertyName) ||
visitNode(cbNode, (<BindingElement>node).name) ||
visitNode(cbNode, (<BindingElement>node).initializer);
case SyntaxKind.FunctionType:
@@ -0,0 +1,6 @@
/// <reference path='fourslash.ts' />
////const { ...a: b } = {};
format.document();
verify.currentFileContentIs("const { ...a: b } = {};");