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

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

Loading…
Cancel
Save