mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix formatter crash for const { ...a: b } = {};: forEachChild and emitBindingElement should handle ... before the propertyName (#21268)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 } = {};");
|
||||
Reference in New Issue
Block a user