set expression end to typeAnnotation end where appropriate

pull/9566/head
Rich Harris 3 years ago
parent 459e4ff006
commit 4b57898ab6

@ -22,12 +22,14 @@ export default function read_context(parser) {
const code = full_char_code_at(parser.template, i);
if (isIdentifierStart(code, true)) {
const name = /** @type {string} */ (parser.read_identifier());
const typeAnnotation = read_type_annotation(parser);
return {
type: 'Identifier',
name,
start,
end: parser.index,
typeAnnotation: read_type_annotation(parser)
typeAnnotation
};
}
@ -81,6 +83,10 @@ export default function read_context(parser) {
).left;
expression.typeAnnotation = read_type_annotation(parser);
if (expression.typeAnnotation) {
expression.end = expression.typeAnnotation.end;
}
return expression;
} catch (error) {
parser.acorn_error(error);

@ -28,7 +28,7 @@
"type": "Identifier",
"name": "msg",
"start": 43,
"end": 46,
"end": 54,
"typeAnnotation": {
"type": "TSStringKeyword",
"start": 48,

Loading…
Cancel
Save