Skip to content

Commit 08b5851

Browse files
fix: append start/end info to more tags (#11930)
* fix: append start/end info to more tags We should add them everywhere we can Related sveltejs/language-tools#2385 * changeset --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 6cf2ec5 commit 08b5851

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/orange-comics-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: append start/end info to `AssignmentPattern` and `VariableDeclarator`

packages/svelte/src/compiler/phases/1-parse/state/tag.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,13 @@ function open(parser) {
281281
parser.allow_whitespace();
282282
if (parser.eat('=')) {
283283
parser.allow_whitespace();
284+
const right = read_expression(parser);
284285
pattern = {
285286
type: 'AssignmentPattern',
286287
left: pattern,
287-
right: read_expression(parser)
288+
right: right,
289+
start: pattern.start,
290+
end: right.end
288291
};
289292
}
290293

@@ -572,7 +575,7 @@ function special(parser) {
572575
declaration: {
573576
type: 'VariableDeclaration',
574577
kind: 'const',
575-
declarations: [{ type: 'VariableDeclarator', id, init }],
578+
declarations: [{ type: 'VariableDeclarator', id, init, start: id.start, end: init.end }],
576579
start: start + 2, // start at const, not at @const
577580
end: parser.index - 1
578581
}

0 commit comments

Comments
 (0)