diff --git a/ecmascript/ast/src/pat.rs b/ecmascript/ast/src/pat.rs index 560c3333eee..33a8c3ced00 100644 --- a/ecmascript/ast/src/pat.rs +++ b/ecmascript/ast/src/pat.rs @@ -63,12 +63,12 @@ pub struct AssignPat { /// EsTree `RestElement` #[ast_node("RestElement")] pub struct RestPat { + pub span: Span, + #[serde(rename = "rest")] - #[span(lo)] pub dot3_token: Span, #[serde(rename = "argument")] - #[span(hi)] pub arg: Box, #[serde(default, rename = "typeAnnotation")] diff --git a/ecmascript/parser/src/parser/expr.rs b/ecmascript/parser/src/parser/expr.rs index ee1d42c0d5a..d145b1db8e3 100644 --- a/ecmascript/parser/src/parser/expr.rs +++ b/ecmascript/parser/src/parser/expr.rs @@ -1120,6 +1120,7 @@ impl<'a, I: Tokens> Parser<'a, I> { let modifier_start = start; let has_modifier = self.eat_any_ts_modifier()?; + let pat_start = cur_pos!(); let mut arg = { if self.input.syntax().typescript() @@ -1227,6 +1228,7 @@ impl<'a, I: Tokens> Parser<'a, I> { } rest_span = Some(span); pat = Pat::Rest(RestPat { + span: span!(pat_start), dot3_token: span, arg: Box::new(pat), type_ann: None, @@ -1234,20 +1236,40 @@ impl<'a, I: Tokens> Parser<'a, I> { } match pat { Pat::Ident(Ident { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Array(ArrayPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Assign(AssignPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Object(ObjectPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Rest(RestPat { - ref mut type_ann, .. - }) => *type_ann = self.try_parse_ts_type_ann()?, + ref mut type_ann, + ref mut span, + .. + }) => { + let new_type_ann = self.try_parse_ts_type_ann()?; + if new_type_ann.is_some() { + *span = Span::new( + pat_start, + self.input.prev_span().hi(), + Default::default(), + ); + } + *type_ann = new_type_ann; + } Pat::Expr(ref expr) => unreachable!("invalid pattern: Expr({:?})", expr), Pat::Invalid(ref i) => unreachable!("invalid pattern: {:?}", i.span), } diff --git a/ecmascript/parser/src/parser/expr/tests.rs b/ecmascript/parser/src/parser/expr/tests.rs index fa0c770037e..3fa58188990 100644 --- a/ecmascript/parser/src/parser/expr/tests.rs +++ b/ecmascript/parser/src/parser/expr/tests.rs @@ -104,6 +104,7 @@ fn object_rest_pat() { params: vec![Pat::Object(ObjectPat { span, props: vec![ObjectPatProp::Rest(RestPat { + span, dot3_token: span, arg: box Pat::Ident(Ident::new("a34".into(), span)), type_ann: None, @@ -220,6 +221,7 @@ fn arrow_fn_rest() { is_async: false, is_generator: false, params: vec![Pat::Rest(RestPat { + span, dot3_token: span, arg: box Pat::Ident(Ident::new("a".into(), span)), type_ann: None diff --git a/ecmascript/parser/src/parser/object.rs b/ecmascript/parser/src/parser/object.rs index 786371c2014..a33b2a4d90a 100644 --- a/ecmascript/parser/src/parser/object.rs +++ b/ecmascript/parser/src/parser/object.rs @@ -390,6 +390,7 @@ impl<'a, I: Tokens> ParseObject<'a, Pat> for Parser<'a, I> { let arg = Box::new(self.parse_binding_pat_or_ident()?); return Ok(ObjectPatProp::Rest(RestPat { + span: span!(start), dot3_token, arg, type_ann: None, diff --git a/ecmascript/parser/src/parser/pat.rs b/ecmascript/parser/src/parser/pat.rs index 42d0ffaab53..93f00f78959 100644 --- a/ecmascript/parser/src/parser/pat.rs +++ b/ecmascript/parser/src/parser/pat.rs @@ -97,6 +97,7 @@ impl<'a, I: Tokens> Parser<'a, I> { let pat = self.parse_binding_pat_or_ident()?; let pat = Pat::Rest(RestPat { + span: span!(start), dot3_token, arg: Box::new(pat), type_ann: None, @@ -143,6 +144,7 @@ impl<'a, I: Tokens> Parser<'a, I> { let has_modifier = self.eat_any_ts_modifier()?; + let pat_start = cur_pos!(); let mut pat = self.parse_binding_element()?; // let mut opt = false; @@ -164,21 +166,36 @@ impl<'a, I: Tokens> Parser<'a, I> { match pat { Pat::Array(ArrayPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Assign(AssignPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Ident(Ident { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Object(ObjectPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) | Pat::Rest(RestPat { - ref mut type_ann, .. + ref mut type_ann, + ref mut span, + .. }) => { - *type_ann = self.try_parse_ts_type_ann()?; + let new_type_ann = self.try_parse_ts_type_ann()?; + if new_type_ann.is_some() { + *span = + Span::new(pat_start, self.input.prev_span().hi(), Default::default()); + } + *type_ann = new_type_ann; } Pat::Invalid(..) => {} _ => unreachable!("invalid syntax: Pat: {:?}", pat), @@ -242,6 +259,7 @@ impl<'a, I: Tokens> Parser<'a, I> { }; let pat = Pat::Rest(RestPat { + span: span!(start), dot3_token, arg: Box::new(pat), type_ann, @@ -341,6 +359,7 @@ impl<'a, I: Tokens> Parser<'a, I> { }; let pat = Pat::Rest(RestPat { + span: span!(start), dot3_token, arg: Box::new(pat), type_ann, @@ -547,6 +566,7 @@ impl<'a, I: Tokens> Parser<'a, I> { PropOrSpread::Spread(SpreadElement { dot3_token, expr }) => { Ok(ObjectPatProp::Rest(RestPat { + span, dot3_token, // FIXME: is BindingPat correct? arg: Box::new( @@ -613,9 +633,11 @@ impl<'a, I: Tokens> Parser<'a, I> { expr, }) => { // TODO: is BindingPat correct? + let expr_span = expr.span(); self.reparse_expr_as_pat(pat_ty.element(), expr) .map(|pat| { Pat::Rest(RestPat { + span: expr_span, dot3_token, arg: Box::new(pat), type_ann: None, @@ -696,13 +718,17 @@ impl<'a, I: Tokens> Parser<'a, I> { PatOrExprOrSpread::ExprOrSpread(ExprOrSpread { spread: Some(dot3_token), expr, - }) => self.reparse_expr_as_pat(pat_ty, expr).map(|pat| { - Pat::Rest(RestPat { - dot3_token, - arg: Box::new(pat), - type_ann: None, - }) - })?, + }) => { + let expr_span = expr.span(); + self.reparse_expr_as_pat(pat_ty, expr).map(|pat| { + Pat::Rest(RestPat { + span: expr_span, + dot3_token, + arg: Box::new(pat), + type_ann: None, + }) + })? + } PatOrExprOrSpread::ExprOrSpread(ExprOrSpread { expr, .. }) => { self.reparse_expr_as_pat(pat_ty, expr)? } diff --git a/ecmascript/parser/src/parser/stmt.rs b/ecmascript/parser/src/parser/stmt.rs index ff8bce93c7a..65150db7a32 100644 --- a/ecmascript/parser/src/parser/stmt.rs +++ b/ecmascript/parser/src/parser/stmt.rs @@ -1155,6 +1155,7 @@ mod tests { param: Pat::Object(ObjectPat { span, props: vec![ObjectPatProp::Rest(RestPat { + span, dot3_token: span, arg: box Pat::Ident(Ident::new("a34".into(), span)), type_ann: None diff --git a/ecmascript/parser/tests/typescript/arrow-function/annotated/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/annotated/input.ts.json index 4d390513353..0d2fd546da3 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/annotated/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/annotated/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 1, - "end": 2, + "end": 10, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/arrow-function/async-generic/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/async-generic/input.ts.json index 04a58490096..dba7f4d0219 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/async-generic/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/async-generic/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 10, - "end": 11, + "end": 14, "ctxt": 0 }, "value": "a", diff --git a/ecmascript/parser/tests/typescript/arrow-function/async-rest-optional-parameter/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/async-rest-optional-parameter/input.ts.json index 63311f0e38c..cbc6ae27485 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/async-rest-optional-parameter/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/async-rest-optional-parameter/input.ts.json @@ -23,6 +23,11 @@ "params": [ { "type": "RestElement", + "span": { + "start": 6, + "end": 21, + "ctxt": 0 + }, "rest": { "start": 6, "end": 9, diff --git a/ecmascript/parser/tests/typescript/arrow-function/async-rest/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/async-rest/input.ts.json index 3f5b182462a..e6b7b12bc51 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/async-rest/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/async-rest/input.ts.json @@ -23,6 +23,11 @@ "params": [ { "type": "RestElement", + "span": { + "start": 7, + "end": 21, + "ctxt": 0 + }, "rest": { "start": 7, "end": 10, diff --git a/ecmascript/parser/tests/typescript/arrow-function/async/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/async/input.ts.json index c7453471b5f..6dad93c7334 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/async/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/async/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 7, - "end": 8, + "end": 17, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/arrow-function/default-parameter-values/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/default-parameter-values/input.ts.json index 443503a9937..3f78fd799ca 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/default-parameter-values/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/default-parameter-values/input.ts.json @@ -32,7 +32,7 @@ "type": "Identifier", "span": { "start": 1, - "end": 2, + "end": 10, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/arrow-function/generic-tsx/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/generic-tsx/input.ts.json index 579cd13f4ec..e7c950c127d 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/generic-tsx/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/generic-tsx/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 66, - "end": 67, + "end": 70, "ctxt": 0 }, "value": "a", diff --git a/ecmascript/parser/tests/typescript/arrow-function/generic/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/generic/input.ts.json index 6368c719f54..0b2f0e1b345 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/generic/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/generic/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 4, - "end": 5, + "end": 8, "ctxt": 0 }, "value": "a", diff --git a/ecmascript/parser/tests/typescript/arrow-function/optional-parameter/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/optional-parameter/input.ts.json index c98e153a694..fbb2a4c8beb 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/optional-parameter/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/optional-parameter/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 1, - "end": 2, + "end": 11, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/arrow-function/predicate-types/input.ts.json b/ecmascript/parser/tests/typescript/arrow-function/predicate-types/input.ts.json index 1d84e47ca88..9cf8a5c9dc9 100644 --- a/ecmascript/parser/tests/typescript/arrow-function/predicate-types/input.ts.json +++ b/ecmascript/parser/tests/typescript/arrow-function/predicate-types/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 1, - "end": 2, + "end": 7, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/class/constructor-with-modifier-names/input.ts.json b/ecmascript/parser/tests/typescript/class/constructor-with-modifier-names/input.ts.json index 5d97f1da735..d682c0dc526 100644 --- a/ecmascript/parser/tests/typescript/class/constructor-with-modifier-names/input.ts.json +++ b/ecmascript/parser/tests/typescript/class/constructor-with-modifier-names/input.ts.json @@ -104,7 +104,7 @@ "type": "Identifier", "span": { "start": 60, - "end": 63, + "end": 68, "ctxt": 0 }, "value": "set", @@ -131,7 +131,7 @@ "type": "Identifier", "span": { "start": 70, - "end": 78, + "end": 87, "ctxt": 0 }, "value": "readonly", diff --git a/ecmascript/parser/tests/typescript/class/constructor/input.ts.json b/ecmascript/parser/tests/typescript/class/constructor/input.ts.json index 6ca4a9ae2cd..de92c658ac0 100644 --- a/ecmascript/parser/tests/typescript/class/constructor/input.ts.json +++ b/ecmascript/parser/tests/typescript/class/constructor/input.ts.json @@ -50,7 +50,7 @@ "type": "Identifier", "span": { "start": 27, - "end": 28, + "end": 36, "ctxt": 0 }, "value": "x", @@ -77,7 +77,7 @@ "type": "Identifier", "span": { "start": 38, - "end": 39, + "end": 47, "ctxt": 0 }, "value": "y", @@ -128,7 +128,7 @@ "type": "Identifier", "span": { "start": 67, - "end": 68, + "end": 76, "ctxt": 0 }, "value": "x", @@ -155,7 +155,7 @@ "type": "Identifier", "span": { "start": 78, - "end": 79, + "end": 87, "ctxt": 0 }, "value": "y", @@ -206,7 +206,7 @@ "type": "Identifier", "span": { "start": 107, - "end": 108, + "end": 113, "ctxt": 0 }, "value": "x", @@ -233,7 +233,7 @@ "type": "Identifier", "span": { "start": 115, - "end": 116, + "end": 121, "ctxt": 0 }, "value": "y", diff --git a/ecmascript/parser/tests/typescript/class/method-generic/input.ts.json b/ecmascript/parser/tests/typescript/class/method-generic/input.ts.json index 3af0f884053..46786cc01fe 100644 --- a/ecmascript/parser/tests/typescript/class/method-generic/input.ts.json +++ b/ecmascript/parser/tests/typescript/class/method-generic/input.ts.json @@ -51,7 +51,7 @@ "type": "Identifier", "span": { "start": 20, - "end": 21, + "end": 24, "ctxt": 0 }, "value": "a", @@ -89,7 +89,7 @@ "type": "Identifier", "span": { "start": 26, - "end": 27, + "end": 31, "ctxt": 0 }, "value": "b", @@ -125,6 +125,11 @@ }, { "type": "RestElement", + "span": { + "start": 33, + "end": 42, + "ctxt": 0 + }, "rest": { "start": 33, "end": 36, diff --git a/ecmascript/parser/tests/typescript/class/parameter-properties/input.ts.json b/ecmascript/parser/tests/typescript/class/parameter-properties/input.ts.json index b17f6d53265..cfdc40d2fac 100644 --- a/ecmascript/parser/tests/typescript/class/parameter-properties/input.ts.json +++ b/ecmascript/parser/tests/typescript/class/parameter-properties/input.ts.json @@ -82,7 +82,7 @@ "type": "Identifier", "span": { "start": 65, - "end": 67, + "end": 75, "ctxt": 0 }, "value": "pu", @@ -142,7 +142,7 @@ "type": "Identifier", "span": { "start": 118, - "end": 120, + "end": 129, "ctxt": 0 }, "value": "pi", @@ -249,7 +249,7 @@ "type": "Identifier", "span": { "start": 246, - "end": 247, + "end": 256, "ctxt": 0 }, "value": "y", diff --git a/ecmascript/parser/tests/typescript/custom/arrow/complex-tsc/input.ts.json b/ecmascript/parser/tests/typescript/custom/arrow/complex-tsc/input.ts.json index c491aca8f6d..071d851d032 100644 --- a/ecmascript/parser/tests/typescript/custom/arrow/complex-tsc/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/arrow/complex-tsc/input.ts.json @@ -116,7 +116,7 @@ "type": "Identifier", "span": { "start": 81, - "end": 86, + "end": 94, "ctxt": 0 }, "value": "nodes", @@ -162,7 +162,7 @@ "type": "Identifier", "span": { "start": 96, - "end": 100, + "end": 125, "ctxt": 0 }, "value": "test", @@ -185,7 +185,7 @@ "type": "Identifier", "span": { "start": 103, - "end": 107, + "end": 113, "ctxt": 0 }, "value": "node", @@ -246,7 +246,7 @@ "type": "Identifier", "span": { "start": 127, - "end": 134, + "end": 143, "ctxt": 0 }, "value": "message", diff --git a/ecmascript/parser/tests/typescript/custom/arrow/complex/input.ts.json b/ecmascript/parser/tests/typescript/custom/arrow/complex/input.ts.json index 91be2fd538d..417c7c7f1ab 100644 --- a/ecmascript/parser/tests/typescript/custom/arrow/complex/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/arrow/complex/input.ts.json @@ -32,7 +32,7 @@ "type": "Identifier", "span": { "start": 49, - "end": 67, + "end": 99, "ctxt": 0 }, "value": "tsConfigSourceFile", @@ -89,7 +89,7 @@ "type": "Identifier", "span": { "start": 101, - "end": 108, + "end": 116, "ctxt": 0 }, "value": "propKey", @@ -116,7 +116,7 @@ "type": "Identifier", "span": { "start": 118, - "end": 130, + "end": 138, "ctxt": 0 }, "value": "elementValue", diff --git a/ecmascript/parser/tests/typescript/custom/default-followed-by-type/arrow/input.ts.json b/ecmascript/parser/tests/typescript/custom/default-followed-by-type/arrow/input.ts.json index 63ae6a9e991..383825d282a 100644 --- a/ecmascript/parser/tests/typescript/custom/default-followed-by-type/arrow/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/default-followed-by-type/arrow/input.ts.json @@ -53,7 +53,7 @@ "type": "Identifier", "span": { "start": 9, - "end": 17, + "end": 25, "ctxt": 0 }, "value": "greeting", @@ -92,7 +92,7 @@ "type": "Identifier", "span": { "start": 37, - "end": 43, + "end": 51, "ctxt": 0 }, "value": "target", diff --git a/ecmascript/parser/tests/typescript/custom/default-followed-by-type/function/input.ts.json b/ecmascript/parser/tests/typescript/custom/default-followed-by-type/function/input.ts.json index 7eca12a27a2..be099e55bdc 100644 --- a/ecmascript/parser/tests/typescript/custom/default-followed-by-type/function/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/default-followed-by-type/function/input.ts.json @@ -32,7 +32,7 @@ "type": "Identifier", "span": { "start": 14, - "end": 22, + "end": 30, "ctxt": 0 }, "value": "greeting", @@ -71,7 +71,7 @@ "type": "Identifier", "span": { "start": 42, - "end": 48, + "end": 56, "ctxt": 0 }, "value": "target", diff --git a/ecmascript/parser/tests/typescript/custom/issue-236/input.ts.json b/ecmascript/parser/tests/typescript/custom/issue-236/input.ts.json index 44f8e087769..ff0c7179ad0 100644 --- a/ecmascript/parser/tests/typescript/custom/issue-236/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/issue-236/input.ts.json @@ -32,7 +32,7 @@ "type": "Identifier", "span": { "start": 52, - "end": 56, + "end": 61, "ctxt": 0 }, "value": "this", @@ -59,7 +59,7 @@ "type": "Identifier", "span": { "start": 63, - "end": 69, + "end": 85, "ctxt": 0 }, "value": "$scope", @@ -111,7 +111,7 @@ "type": "Identifier", "span": { "start": 87, - "end": 93, + "end": 114, "ctxt": 0 }, "value": "$attrs", diff --git a/ecmascript/parser/tests/typescript/custom/issue-433-2/input.ts.json b/ecmascript/parser/tests/typescript/custom/issue-433-2/input.ts.json index 6258a9de8d3..fbfac8d5793 100644 --- a/ecmascript/parser/tests/typescript/custom/issue-433-2/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/issue-433-2/input.ts.json @@ -60,7 +60,7 @@ "type": "Identifier", "span": { "start": 18, - "end": 19, + "end": 27, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/custom/issue-496/input.ts.json b/ecmascript/parser/tests/typescript/custom/issue-496/input.ts.json index d1f40195c33..2b0eb7c7962 100644 --- a/ecmascript/parser/tests/typescript/custom/issue-496/input.ts.json +++ b/ecmascript/parser/tests/typescript/custom/issue-496/input.ts.json @@ -102,7 +102,7 @@ "type": "Identifier", "span": { "start": 62, - "end": 69, + "end": 74, "ctxt": 0 }, "value": "variant", diff --git a/ecmascript/parser/tests/typescript/es2019/from-entries/input.ts.json b/ecmascript/parser/tests/typescript/es2019/from-entries/input.ts.json index 75761479c58..986649f61d8 100644 --- a/ecmascript/parser/tests/typescript/es2019/from-entries/input.ts.json +++ b/ecmascript/parser/tests/typescript/es2019/from-entries/input.ts.json @@ -61,7 +61,7 @@ "type": "Identifier", "span": { "start": 58, - "end": 65, + "end": 102, "ctxt": 0 }, "value": "entries", @@ -308,7 +308,7 @@ "type": "Identifier", "span": { "start": 149, - "end": 156, + "end": 182, "ctxt": 0 }, "value": "entries", diff --git a/ecmascript/parser/tests/typescript/function/annotated/input.ts.json b/ecmascript/parser/tests/typescript/function/annotated/input.ts.json index 48b0c6904ea..bcfe9e8d420 100644 --- a/ecmascript/parser/tests/typescript/function/annotated/input.ts.json +++ b/ecmascript/parser/tests/typescript/function/annotated/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 14, - "end": 15, + "end": 19, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/function/anonymous/input.ts.json b/ecmascript/parser/tests/typescript/function/anonymous/input.ts.json index 6a362047dfd..379552f03db 100644 --- a/ecmascript/parser/tests/typescript/function/anonymous/input.ts.json +++ b/ecmascript/parser/tests/typescript/function/anonymous/input.ts.json @@ -42,7 +42,7 @@ "type": "Identifier", "span": { "start": 22, - "end": 23, + "end": 27, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/function/export-default/input.ts.json b/ecmascript/parser/tests/typescript/function/export-default/input.ts.json index 42675091cb1..955f4c6cae2 100644 --- a/ecmascript/parser/tests/typescript/function/export-default/input.ts.json +++ b/ecmascript/parser/tests/typescript/function/export-default/input.ts.json @@ -21,7 +21,7 @@ "type": "Identifier", "span": { "start": 24, - "end": 25, + "end": 34, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/function/overloads/input.ts.json b/ecmascript/parser/tests/typescript/function/overloads/input.ts.json index d96d2bc08bc..1c469f54827 100644 --- a/ecmascript/parser/tests/typescript/function/overloads/input.ts.json +++ b/ecmascript/parser/tests/typescript/function/overloads/input.ts.json @@ -32,7 +32,7 @@ "type": "Identifier", "span": { "start": 18, - "end": 19, + "end": 27, "ctxt": 0 }, "value": "x", @@ -111,7 +111,7 @@ "type": "Identifier", "span": { "start": 57, - "end": 58, + "end": 66, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/function/predicate-types/input.ts.json b/ecmascript/parser/tests/typescript/function/predicate-types/input.ts.json index d34822dbb9e..6e6fb212ef4 100644 --- a/ecmascript/parser/tests/typescript/function/predicate-types/input.ts.json +++ b/ecmascript/parser/tests/typescript/function/predicate-types/input.ts.json @@ -25,7 +25,7 @@ "type": "Identifier", "span": { "start": 11, - "end": 12, + "end": 17, "ctxt": 0 }, "value": "x", @@ -134,7 +134,7 @@ "type": "Identifier", "span": { "start": 47, - "end": 48, + "end": 53, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/interface/call-signature/input.ts.json b/ecmascript/parser/tests/typescript/interface/call-signature/input.ts.json index 276f870fd5e..712fbaefa03 100644 --- a/ecmascript/parser/tests/typescript/interface/call-signature/input.ts.json +++ b/ecmascript/parser/tests/typescript/interface/call-signature/input.ts.json @@ -47,7 +47,7 @@ "type": "Identifier", "span": { "start": 20, - "end": 21, + "end": 29, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/interface/construct-signature/input.ts.json b/ecmascript/parser/tests/typescript/interface/construct-signature/input.ts.json index 82fb016373f..3088365b2a4 100644 --- a/ecmascript/parser/tests/typescript/interface/construct-signature/input.ts.json +++ b/ecmascript/parser/tests/typescript/interface/construct-signature/input.ts.json @@ -47,7 +47,7 @@ "type": "Identifier", "span": { "start": 24, - "end": 25, + "end": 33, "ctxt": 0 }, "value": "x", diff --git a/ecmascript/parser/tests/typescript/interface/method-plain/input.ts.json b/ecmascript/parser/tests/typescript/interface/method-plain/input.ts.json index b6772accf01..bc906d32c7b 100644 --- a/ecmascript/parser/tests/typescript/interface/method-plain/input.ts.json +++ b/ecmascript/parser/tests/typescript/interface/method-plain/input.ts.json @@ -86,7 +86,7 @@ "type": "Identifier", "span": { "start": 31, - "end": 32, + "end": 41, "ctxt": 0 }, "value": "x", @@ -111,6 +111,11 @@ }, { "type": "RestElement", + "span": { + "start": 43, + "end": 57, + "ctxt": 0 + }, "rest": { "start": 43, "end": 46, diff --git a/ecmascript/parser/tests/typescript/regression/destructuring-in-function-type/input.ts.json b/ecmascript/parser/tests/typescript/regression/destructuring-in-function-type/input.ts.json index 6a557e0a203..3326df71963 100644 --- a/ecmascript/parser/tests/typescript/regression/destructuring-in-function-type/input.ts.json +++ b/ecmascript/parser/tests/typescript/regression/destructuring-in-function-type/input.ts.json @@ -38,7 +38,7 @@ "type": "ObjectPattern", "span": { "start": 15, - "end": 24, + "end": 29, "ctxt": 0 }, "properties": [ diff --git a/ecmascript/parser/tests/typescript/regression/tsx-issue-7742/input.ts.json b/ecmascript/parser/tests/typescript/regression/tsx-issue-7742/input.ts.json index e33672863e4..c1eff8a6791 100644 --- a/ecmascript/parser/tests/typescript/regression/tsx-issue-7742/input.ts.json +++ b/ecmascript/parser/tests/typescript/regression/tsx-issue-7742/input.ts.json @@ -77,7 +77,7 @@ "type": "Identifier", "span": { "start": 28, - "end": 31, + "end": 34, "ctxt": 0 }, "value": "bar", diff --git a/ecmascript/parser/tests/typescript/types/function-generic/input.ts.json b/ecmascript/parser/tests/typescript/types/function-generic/input.ts.json index 8f61ac631ef..9f365ff84d4 100644 --- a/ecmascript/parser/tests/typescript/types/function-generic/input.ts.json +++ b/ecmascript/parser/tests/typescript/types/function-generic/input.ts.json @@ -50,7 +50,7 @@ "type": "Identifier", "span": { "start": 11, - "end": 12, + "end": 15, "ctxt": 0 }, "value": "a", diff --git a/ecmascript/parser/tests/typescript/types/function-with-this/input.ts.json b/ecmascript/parser/tests/typescript/types/function-with-this/input.ts.json index caa42ecb23d..e4b1126250b 100644 --- a/ecmascript/parser/tests/typescript/types/function-with-this/input.ts.json +++ b/ecmascript/parser/tests/typescript/types/function-with-this/input.ts.json @@ -50,7 +50,7 @@ "type": "Identifier", "span": { "start": 8, - "end": 12, + "end": 20, "ctxt": 0 }, "value": "this", diff --git a/ecmascript/parser/tests/typescript/types/function/input.ts.json b/ecmascript/parser/tests/typescript/types/function/input.ts.json index 51f52156fa8..a713c4f9785 100644 --- a/ecmascript/parser/tests/typescript/types/function/input.ts.json +++ b/ecmascript/parser/tests/typescript/types/function/input.ts.json @@ -50,7 +50,7 @@ "type": "Identifier", "span": { "start": 8, - "end": 9, + "end": 17, "ctxt": 0 }, "value": "a", @@ -77,7 +77,7 @@ "type": "Identifier", "span": { "start": 19, - "end": 20, + "end": 29, "ctxt": 0 }, "value": "b", @@ -102,6 +102,11 @@ }, { "type": "RestElement", + "span": { + "start": 31, + "end": 45, + "ctxt": 0 + }, "rest": { "start": 31, "end": 34, diff --git a/ecmascript/parser/tests/typescript/types/object-shorthand/input.ts.json b/ecmascript/parser/tests/typescript/types/object-shorthand/input.ts.json index f05a4c80dbe..8bb11df9b47 100644 --- a/ecmascript/parser/tests/typescript/types/object-shorthand/input.ts.json +++ b/ecmascript/parser/tests/typescript/types/object-shorthand/input.ts.json @@ -60,7 +60,7 @@ "type": "Identifier", "span": { "start": 49, - "end": 54, + "end": 57, "ctxt": 0 }, "value": "value", diff --git a/ecmascript/parser/tests/typescript/types/tuple-rest-after-optional/input.ts.json b/ecmascript/parser/tests/typescript/types/tuple-rest-after-optional/input.ts.json index 419f2c6541f..205f3da3dc0 100644 --- a/ecmascript/parser/tests/typescript/types/tuple-rest-after-optional/input.ts.json +++ b/ecmascript/parser/tests/typescript/types/tuple-rest-after-optional/input.ts.json @@ -23,6 +23,11 @@ "params": [ { "type": "RestElement", + "span": { + "start": 13, + "end": 52, + "ctxt": 0 + }, "rest": { "start": 13, "end": 16, diff --git a/ecmascript/transforms/src/compat/es2017/async_to_generator.rs b/ecmascript/transforms/src/compat/es2017/async_to_generator.rs index 25168be3b49..03bd4824758 100644 --- a/ecmascript/transforms/src/compat/es2017/async_to_generator.rs +++ b/ecmascript/transforms/src/compat/es2017/async_to_generator.rs @@ -255,6 +255,7 @@ impl Fold for MethodFolder { is_async: false, is_generator: false, params: vec![Pat::Rest(RestPat { + span: DUMMY_SP, dot3_token: DUMMY_SP, arg: box Pat::Ident(args_ident.clone()), type_ann: Default::default(), diff --git a/ecmascript/transforms/src/proposals/decorators.rs b/ecmascript/transforms/src/proposals/decorators.rs index bc2a391f4c0..6de71bce65a 100644 --- a/ecmascript/transforms/src/proposals/decorators.rs +++ b/ecmascript/transforms/src/proposals/decorators.rs @@ -269,6 +269,7 @@ impl Decorators { accessibility: Default::default(), params: if super_class_ident.is_some() { vec![PatOrTsParamProp::Pat(Pat::Rest(RestPat { + span: DUMMY_SP, dot3_token: DUMMY_SP, arg: box Pat::Ident(quote_ident!("args")), type_ann: Default::default(), diff --git a/ecmascript/transforms/src/util.rs b/ecmascript/transforms/src/util.rs index 7d98367d10b..7b11c2bd704 100644 --- a/ecmascript/transforms/src/util.rs +++ b/ecmascript/transforms/src/util.rs @@ -1291,6 +1291,7 @@ pub fn default_constructor(has_super: bool) -> Constructor { is_optional: false, params: if has_super { vec![PatOrTsParamProp::Pat(Pat::Rest(RestPat { + span: DUMMY_SP, dot3_token: DUMMY_SP, arg: box Pat::Ident(quote_ident!(span, "args")), type_ann: Default::default(),