Skip to content

Commit 4b57898

Browse files
committed
set expression end to typeAnnotation end where appropriate
1 parent 459e4ff commit 4b57898

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/svelte/src/compiler/phases/1-parse/read/context.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ export default function read_context(parser) {
2222
const code = full_char_code_at(parser.template, i);
2323
if (isIdentifierStart(code, true)) {
2424
const name = /** @type {string} */ (parser.read_identifier());
25+
const typeAnnotation = read_type_annotation(parser);
26+
2527
return {
2628
type: 'Identifier',
2729
name,
2830
start,
2931
end: parser.index,
30-
typeAnnotation: read_type_annotation(parser)
32+
typeAnnotation
3133
};
3234
}
3335

@@ -81,6 +83,10 @@ export default function read_context(parser) {
8183
).left;
8284

8385
expression.typeAnnotation = read_type_annotation(parser);
86+
if (expression.typeAnnotation) {
87+
expression.end = expression.typeAnnotation.end;
88+
}
89+
8490
return expression;
8591
} catch (error) {
8692
parser.acorn_error(error);

packages/svelte/tests/parser-modern/samples/snippets/output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"type": "Identifier",
2929
"name": "msg",
3030
"start": 43,
31-
"end": 46,
31+
"end": 54,
3232
"typeAnnotation": {
3333
"type": "TSStringKeyword",
3434
"start": 48,

0 commit comments

Comments
 (0)