mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
Fix spans for "as" and const assertions (#593)
- Fix spans for "as" and const assertions
This commit is contained in:
parent
2880250309
commit
a55fced20b
@ -73,17 +73,20 @@ impl<'a, I: Tokens> Parser<'a, I> {
|
||||
&& !self.input.had_line_break_before_cur()
|
||||
&& is!("as")
|
||||
{
|
||||
let span = span!(left.span().lo());
|
||||
let start = left.span().lo();
|
||||
let expr = left;
|
||||
let node = if peeked_is!("const") {
|
||||
bump!(); // as
|
||||
let _ = cur!(false);
|
||||
bump!(); // const
|
||||
Box::new(Expr::TsConstAssertion(TsConstAssertion { span, expr }))
|
||||
Box::new(Expr::TsConstAssertion(TsConstAssertion {
|
||||
span: span!(start),
|
||||
expr,
|
||||
}))
|
||||
} else {
|
||||
let type_ann = self.next_then_parse_ts_type()?;
|
||||
Box::new(Expr::TsAs(TsAsExpr {
|
||||
span,
|
||||
span: span!(start),
|
||||
expr,
|
||||
type_ann,
|
||||
}))
|
||||
|
@ -17,7 +17,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 1,
|
||||
"end": 6,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
@ -64,7 +64,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 8,
|
||||
"end": 13,
|
||||
"end": 24,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
@ -120,7 +120,7 @@
|
||||
"type": "BinaryExpression",
|
||||
"span": {
|
||||
"start": 49,
|
||||
"end": 56,
|
||||
"end": 66,
|
||||
"ctxt": 0
|
||||
},
|
||||
"operator": "===",
|
||||
@ -139,7 +139,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 55,
|
||||
"end": 56,
|
||||
"end": 66,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
@ -174,14 +174,14 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 92,
|
||||
"end": 100,
|
||||
"end": 105,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 92,
|
||||
"end": 93,
|
||||
"end": 100,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
|
@ -25,7 +25,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 1,
|
||||
"end": 2,
|
||||
"end": 12,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
|
@ -25,14 +25,14 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 1,
|
||||
"end": 12,
|
||||
"end": 19,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 1,
|
||||
"end": 2,
|
||||
"end": 12,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
|
@ -106,7 +106,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"end": 18,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
|
@ -38,7 +38,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 12,
|
||||
"end": 26,
|
||||
"end": 50,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
|
@ -38,7 +38,7 @@
|
||||
"type": "TsAsExpression",
|
||||
"span": {
|
||||
"start": 12,
|
||||
"end": 15,
|
||||
"end": 37,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expression": {
|
||||
|
@ -38,7 +38,7 @@
|
||||
"type": "TsConstAssertion",
|
||||
"span": {
|
||||
"start": 8,
|
||||
"end": 16,
|
||||
"end": 25,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expr": {
|
||||
|
@ -38,7 +38,7 @@
|
||||
"type": "TsConstAssertion",
|
||||
"span": {
|
||||
"start": 8,
|
||||
"end": 15,
|
||||
"end": 24,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expr": {
|
||||
|
@ -38,7 +38,7 @@
|
||||
"type": "TsConstAssertion",
|
||||
"span": {
|
||||
"start": 8,
|
||||
"end": 25,
|
||||
"end": 34,
|
||||
"ctxt": 0
|
||||
},
|
||||
"expr": {
|
||||
|
Loading…
Reference in New Issue
Block a user