Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff00a0c

Browse filesBrowse files
committed
Fix breakpoints in object literal pattern destructuring assignment
1 parent db0ab40 commit ff00a0c
Copy full SHA for ff00a0c

4 files changed

+2,673-7Lines changed: 2673 additions & 7 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/breakpoints.ts‎

Copy file name to clipboardExpand all lines: src/services/breakpoints.ts
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ namespace ts.BreakpointResolver {
261261
}
262262

263263
// Set breakpoint on identifier element of destructuring pattern
264-
// a or ...c from
265-
// [a, b, ...c] or { a, b } from destructuring pattern
266-
if ((node.kind === SyntaxKind.Identifier || node.kind == SyntaxKind.SpreadElementExpression) &&
264+
// a or ...c or d: x from
265+
// [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
266+
if ((node.kind === SyntaxKind.Identifier ||
267+
node.kind == SyntaxKind.SpreadElementExpression ||
268+
node.kind === SyntaxKind.PropertyAssignment ||
269+
node.kind === SyntaxKind.ShorthandPropertyAssignment) &&
267270
isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
268271
return textSpan(node);
269272
}
@@ -322,12 +325,14 @@ namespace ts.BreakpointResolver {
322325
break;
323326
}
324327
}
325-
328+
326329
// If this is name of property assignment, set breakpoint in the initializer
327-
if (node.parent.kind === SyntaxKind.PropertyAssignment && (<PropertyDeclaration>node.parent).name === node) {
330+
if (node.parent.kind === SyntaxKind.PropertyAssignment &&
331+
(<PropertyDeclaration>node.parent).name === node &&
332+
!isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) {
328333
return spanInNode((<PropertyDeclaration>node.parent).initializer);
329334
}
330-
335+
331336
// Breakpoint in type assertion goes to its operand
332337
if (node.parent.kind === SyntaxKind.TypeAssertionExpression && (<TypeAssertion>node.parent).type === node) {
333338
return spanInNextNode((<TypeAssertion>node.parent).type);
@@ -609,6 +614,11 @@ namespace ts.BreakpointResolver {
609614

610615
// Default to parent node
611616
default:
617+
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
618+
// Breakpoint in last binding element or binding pattern if it contains no elements
619+
let objectLiteral = <ObjectLiteralExpression>node.parent;
620+
return textSpan(lastOrUndefined(objectLiteral.properties) || objectLiteral);
621+
}
612622
return spanInNode(node.parent);
613623
}
614624
}
Collapse file

‎src/services/utilities.ts‎

Copy file name to clipboardExpand all lines: src/services/utilities.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,9 @@ namespace ts {
629629

630630
// [a, b, c] of
631631
// [x, [a, b, c] ] = someExpression
632-
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
632+
// or
633+
// {x, a: {a, b, c} } = someExpression
634+
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === SyntaxKind.PropertyAssignment ? node.parent.parent : node.parent)) {
633635
return true;
634636
}
635637
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.