Store span of ?. in an optional chaining expression (#907)

Add OptChainExpr.question_dot_token
This commit is contained in:
강동윤 2020-07-28 02:15:04 +09:00 committed by GitHub
parent 891092caf2
commit de1f967d32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 2934 additions and 68 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_ast"
version = "0.25.0"
version = "0.26.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"

View File

@ -577,6 +577,7 @@ impl From<Str> for Expr {
#[derive(Eq, Hash)]
pub struct OptChainExpr {
pub span: Span,
pub question_dot_token: Span,
pub expr: Box<Expr>,
}

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_codegen"
version = "0.28.3"
version = "0.29.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"
@ -13,11 +13,11 @@ include = ["Cargo.toml", "src/**/*.rs"]
bitflags = "1"
swc_atoms = { version = "0.2", path ="../../atoms" }
swc_common = { version = "0.7", path ="../../common" }
swc_ecma_ast = { version = "0.25.0", path ="../ast" }
swc_ecma_ast = { version = "0.26.0", path ="../ast" }
swc_ecma_codegen_macros = { version = "0.5", path ="./macros" }
sourcemap = "6"
num-bigint = { version = "0.2", features = ["serde"] }
[dev-dependencies]
swc_ecma_parser = { version = "0.30", path ="../parser" }
swc_ecma_parser = { version = "0.31", path ="../parser" }
testing = { version = "0.7", path ="../../testing" }

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_parser"
version = "0.30.1"
version = "0.31.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"
@ -15,9 +15,9 @@ default = []
[dependencies]
swc_atoms = { version = "0.2", path ="../../atoms" }
swc_common = { version = "0.7.0", path ="../../common" }
swc_ecma_ast = { version = "0.25.0", path ="../ast" }
swc_ecma_ast = { version = "0.26.0", path ="../ast" }
swc_ecma_parser_macros = { version = "0.4.1", path ="./macros" }
swc_ecma_visit = { version = "0.10.0", path ="../visit" }
swc_ecma_visit = { version = "0.11.0", path ="../visit" }
enum_kind = { version = "0.2", path ="../../macros/enum_kind" }
unicode-xid = "0.2"
log = "0.4"

View File

@ -946,15 +946,22 @@ impl<'a, I: Tokens> Parser<I> {
}
}
let is_optional_chaining =
self.input.syntax().optional_chaining() && is!('?') && peeked_is!('.') && eat!('?');
let question_dot_token =
if self.input.syntax().optional_chaining() && is!('?') && peeked_is!('.') {
let start = cur_pos!();
eat!('?');
Some(span!(start))
} else {
None
};
/// Wrap with optional chaining
macro_rules! wrap {
($e:expr) => {{
if is_optional_chaining {
if let Some(question_dot_token) = question_dot_token {
Expr::OptChain(OptChainExpr {
span: span!(self, start),
question_dot_token,
expr: Box::new($e),
})
} else {
@ -964,7 +971,7 @@ impl<'a, I: Tokens> Parser<I> {
}
// $obj[name()]
if (is_optional_chaining && is!('.') && peeked_is!('[') && eat!('.') && eat!('['))
if (question_dot_token.is_some() && is!('.') && peeked_is!('[') && eat!('.') && eat!('['))
|| eat!('[')
{
let prop = self.include_in_expr(true).parse_expr()?;
@ -983,7 +990,7 @@ impl<'a, I: Tokens> Parser<I> {
));
}
if (is_optional_chaining && is!('.') && peeked_is!('(') && eat!('.'))
if (question_dot_token.is_some() && is!('.') && peeked_is!('(') && eat!('.'))
|| (!no_call && (is!('(')))
{
let args = self.parse_args(is_import(&obj))?;

View File

@ -0,0 +1,4 @@
foo?.class.bar
foo?.function.bar
foo?.bar?.class.bar
foo?.function?.bar

View File

@ -0,0 +1,345 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 71,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 14,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 14,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 10,
"ctxt": 0
},
"questionDotToken": {
"start": 3,
"end": 4,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 10,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 3,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 5,
"end": 10,
"ctxt": 0
},
"value": "class",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 11,
"end": 14,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 15,
"end": 32,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 32,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 15,
"end": 28,
"ctxt": 0
},
"questionDotToken": {
"start": 18,
"end": 19,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 28,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 15,
"end": 18,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 20,
"end": 28,
"ctxt": 0
},
"value": "function",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 29,
"end": 32,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 33,
"end": 52,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 33,
"end": 52,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 33,
"end": 48,
"ctxt": 0
},
"questionDotToken": {
"start": 41,
"end": 42,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 33,
"end": 48,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 33,
"end": 41,
"ctxt": 0
},
"questionDotToken": {
"start": 36,
"end": 37,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 33,
"end": 41,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 33,
"end": 36,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 38,
"end": 41,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 43,
"end": 48,
"ctxt": 0
},
"value": "class",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 49,
"end": 52,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 53,
"end": 71,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 53,
"end": 71,
"ctxt": 0
},
"questionDotToken": {
"start": 66,
"end": 67,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 53,
"end": 71,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 53,
"end": 66,
"ctxt": 0
},
"questionDotToken": {
"start": 56,
"end": 57,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 53,
"end": 66,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 53,
"end": 56,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 58,
"end": 66,
"ctxt": 0
},
"value": "function",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 68,
"end": 71,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,93 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 12,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 12,
"ctxt": 0
},
"expression": {
"type": "NewExpression",
"span": {
"start": 0,
"end": 12,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 4,
"end": 10,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 4,
"end": 8,
"ctxt": 0
},
"questionDotToken": {
"start": 5,
"end": 6,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 4,
"end": 8,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "C",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 9,
"end": 10,
"ctxt": 0
},
"value": "d",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"arguments": [],
"typeArguments": null
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,3 @@
true?.3:0
true ? .3 : 0

View File

@ -0,0 +1,97 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 24,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"expression": {
"type": "ConditionalExpression",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 0,
"end": 4,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "NumericLiteral",
"span": {
"start": 5,
"end": 7,
"ctxt": 0
},
"value": 0.3
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 8,
"end": 9,
"ctxt": 0
},
"value": 0.0
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 11,
"end": 24,
"ctxt": 0
},
"expression": {
"type": "ConditionalExpression",
"span": {
"start": 11,
"end": 24,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 11,
"end": 15,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "NumericLiteral",
"span": {
"start": 18,
"end": 20,
"ctxt": 0
},
"value": 0.3
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 23,
"end": 24,
"ctxt": 0
},
"value": 0.0
}
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,9 @@
func?.()
func?.(a, b)
a?.func?.()
a?.func?.(a, b)
a.func?.()

View File

@ -0,0 +1,365 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 64,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"questionDotToken": {
"start": 4,
"end": 5,
"ctxt": 0
},
"expr": {
"type": "CallExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 0,
"end": 4,
"ctxt": 0
},
"value": "func",
"typeAnnotation": null,
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 10,
"end": 22,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 10,
"end": 22,
"ctxt": 0
},
"questionDotToken": {
"start": 14,
"end": 15,
"ctxt": 0
},
"expr": {
"type": "CallExpression",
"span": {
"start": 10,
"end": 22,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 10,
"end": 14,
"ctxt": 0
},
"value": "func",
"typeAnnotation": null,
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 17,
"end": 18,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
}
},
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 20,
"end": 21,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
}
}
],
"typeArguments": null
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 24,
"end": 35,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 24,
"end": 35,
"ctxt": 0
},
"questionDotToken": {
"start": 31,
"end": 32,
"ctxt": 0
},
"expr": {
"type": "CallExpression",
"span": {
"start": 24,
"end": 35,
"ctxt": 0
},
"callee": {
"type": "OptionalChainingExpression",
"span": {
"start": 24,
"end": 31,
"ctxt": 0
},
"questionDotToken": {
"start": 25,
"end": 26,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 24,
"end": 31,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 24,
"end": 25,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 27,
"end": 31,
"ctxt": 0
},
"value": "func",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"arguments": [],
"typeArguments": null
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 37,
"end": 52,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 37,
"end": 52,
"ctxt": 0
},
"questionDotToken": {
"start": 44,
"end": 45,
"ctxt": 0
},
"expr": {
"type": "CallExpression",
"span": {
"start": 37,
"end": 52,
"ctxt": 0
},
"callee": {
"type": "OptionalChainingExpression",
"span": {
"start": 37,
"end": 44,
"ctxt": 0
},
"questionDotToken": {
"start": 38,
"end": 39,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 37,
"end": 44,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 40,
"end": 44,
"ctxt": 0
},
"value": "func",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 47,
"end": 48,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
}
},
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
}
}
],
"typeArguments": null
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 54,
"end": 64,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 54,
"end": 64,
"ctxt": 0
},
"questionDotToken": {
"start": 60,
"end": 61,
"ctxt": 0
},
"expr": {
"type": "CallExpression",
"span": {
"start": 54,
"end": 64,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 54,
"end": 60,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 54,
"end": 55,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 56,
"end": 60,
"ctxt": 0
},
"value": "func",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"arguments": [],
"typeArguments": null
}
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,11 @@
obj?.[expr]
obj?.[expr]?.[other]
obj?.[true]
obj?.[true]?.[true]
obj.a?.[expr]
obj.a?.[true]

View File

@ -0,0 +1,421 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 97,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 11,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 11,
"ctxt": 0
},
"questionDotToken": {
"start": 3,
"end": 4,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 11,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 3,
"ctxt": 0
},
"value": "obj",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 6,
"end": 10,
"ctxt": 0
},
"value": "expr",
"typeAnnotation": null,
"optional": false
},
"computed": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 13,
"end": 33,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 13,
"end": 33,
"ctxt": 0
},
"questionDotToken": {
"start": 24,
"end": 25,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 13,
"end": 33,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 13,
"end": 24,
"ctxt": 0
},
"questionDotToken": {
"start": 16,
"end": 17,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 13,
"end": 24,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 13,
"end": 16,
"ctxt": 0
},
"value": "obj",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 19,
"end": 23,
"ctxt": 0
},
"value": "expr",
"typeAnnotation": null,
"optional": false
},
"computed": true
}
},
"property": {
"type": "Identifier",
"span": {
"start": 27,
"end": 32,
"ctxt": 0
},
"value": "other",
"typeAnnotation": null,
"optional": false
},
"computed": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 35,
"end": 46,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 35,
"end": 46,
"ctxt": 0
},
"questionDotToken": {
"start": 38,
"end": 39,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 35,
"end": 46,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 35,
"end": 38,
"ctxt": 0
},
"value": "obj",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "BooleanLiteral",
"span": {
"start": 41,
"end": 45,
"ctxt": 0
},
"value": true
},
"computed": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 48,
"end": 67,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 48,
"end": 67,
"ctxt": 0
},
"questionDotToken": {
"start": 59,
"end": 60,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 48,
"end": 67,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 48,
"end": 59,
"ctxt": 0
},
"questionDotToken": {
"start": 51,
"end": 52,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 48,
"end": 59,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 48,
"end": 51,
"ctxt": 0
},
"value": "obj",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "BooleanLiteral",
"span": {
"start": 54,
"end": 58,
"ctxt": 0
},
"value": true
},
"computed": true
}
},
"property": {
"type": "BooleanLiteral",
"span": {
"start": 62,
"end": 66,
"ctxt": 0
},
"value": true
},
"computed": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 69,
"end": 82,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 69,
"end": 82,
"ctxt": 0
},
"questionDotToken": {
"start": 74,
"end": 75,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 69,
"end": 82,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 69,
"end": 74,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 69,
"end": 72,
"ctxt": 0
},
"value": "obj",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 77,
"end": 81,
"ctxt": 0
},
"value": "expr",
"typeAnnotation": null,
"optional": false
},
"computed": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 84,
"end": 97,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 84,
"end": 97,
"ctxt": 0
},
"questionDotToken": {
"start": 89,
"end": 90,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 84,
"end": 97,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 84,
"end": 89,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 84,
"end": 87,
"ctxt": 0
},
"value": "obj",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 88,
"end": 89,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "BooleanLiteral",
"span": {
"start": 92,
"end": 96,
"ctxt": 0
},
"value": true
},
"computed": true
}
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,5 @@
foo?.bar
foo?.bar?.baz
foo.bar?.baz

View File

@ -0,0 +1,220 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 37,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"questionDotToken": {
"start": 3,
"end": 4,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 3,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 5,
"end": 8,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 10,
"end": 23,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 10,
"end": 23,
"ctxt": 0
},
"questionDotToken": {
"start": 18,
"end": 19,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 10,
"end": 23,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 10,
"end": 18,
"ctxt": 0
},
"questionDotToken": {
"start": 13,
"end": 14,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 10,
"end": 18,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 10,
"end": 13,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 15,
"end": 18,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 20,
"end": 23,
"ctxt": 0
},
"value": "baz",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 25,
"end": 37,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 25,
"end": 37,
"ctxt": 0
},
"questionDotToken": {
"start": 32,
"end": 33,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 25,
"end": 37,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 25,
"end": 32,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 25,
"end": 28,
"ctxt": 0
},
"value": "foo",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 29,
"end": 32,
"ctxt": 0
},
"value": "bar",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 34,
"end": 37,
"ctxt": 0
},
"value": "baz",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,93 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"callee": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 6,
"ctxt": 0
},
"questionDotToken": {
"start": 3,
"end": 4,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 6,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 3,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 2,
"end": 3,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"arguments": [],
"typeArguments": null
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,63 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 10,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 10,
"ctxt": 0
},
"expression": {
"type": "NewExpression",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"callee": {
"type": "OptionalChainingExpression",
"span": {
"start": 4,
"end": 9,
"ctxt": 0
},
"questionDotToken": {
"start": 5,
"end": 6,
"ctxt": 0
},
"expr": {
"type": "CallExpression",
"span": {
"start": 4,
"end": 9,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"arguments": [],
"typeArguments": null
}
},
"arguments": null,
"typeArguments": null
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,5 @@
class A{
b(){
return super?.b;
}
}

View File

@ -0,0 +1,135 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 50,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "A",
"typeAnnotation": null,
"optional": false
},
"declare": false,
"span": {
"start": 0,
"end": 50,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassMethod",
"span": {
"start": 13,
"end": 48,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 13,
"end": 48,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 16,
"end": 48,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 26,
"end": 42,
"ctxt": 0
},
"argument": {
"type": "OptionalChainingExpression",
"span": {
"start": 33,
"end": 41,
"ctxt": 0
},
"questionDotToken": {
"start": 38,
"end": 39,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 33,
"end": 41,
"ctxt": 0
},
"object": {
"type": "Super",
"span": {
"start": 33,
"end": 38,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 40,
"end": 41,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}

View File

@ -0,0 +1,5 @@
const a = {
b(){
return super?.c;
}
}

View File

@ -0,0 +1,137 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 53,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 53,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 6,
"end": 53,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 10,
"end": 53,
"ctxt": 0
},
"properties": [
{
"type": "MethodProperty",
"key": {
"type": "Identifier",
"span": {
"start": 16,
"end": 17,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"params": [],
"decorators": [],
"span": {
"start": 16,
"end": 51,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 19,
"end": 51,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 29,
"end": 45,
"ctxt": 0
},
"argument": {
"type": "OptionalChainingExpression",
"span": {
"start": 36,
"end": 44,
"ctxt": 0
},
"questionDotToken": {
"start": 41,
"end": 42,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 36,
"end": 44,
"ctxt": 0
},
"object": {
"type": "Super",
"span": {
"start": 36,
"end": 41,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 43,
"end": 44,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
]
},
"definite": false
}
]
}
],
"interpreter": null
}

View File

@ -0,0 +1,104 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"expression": {
"type": "TaggedTemplateExpression",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"tag": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 4,
"ctxt": 0
},
"questionDotToken": {
"start": 1,
"end": 2,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 4,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 3,
"end": 4,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 5,
"end": 8,
"ctxt": 0
},
"tail": true,
"cooked": {
"type": "StringLiteral",
"span": {
"start": 5,
"end": 8,
"ctxt": 0
},
"value": "foo",
"hasEscape": false
},
"raw": {
"type": "StringLiteral",
"span": {
"start": 5,
"end": 8,
"ctxt": 0
},
"value": "foo",
"hasEscape": false
}
}
],
"typeParameters": null
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,5 @@
(a?.b).c;
(a?.b).c();
(a?.b)?.c.d?.e;

View File

@ -0,0 +1,327 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 39,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 9,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 0,
"end": 6,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 1,
"end": 5,
"ctxt": 0
},
"questionDotToken": {
"start": 2,
"end": 3,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 1,
"end": 5,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 1,
"end": 2,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 11,
"end": 22,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 11,
"end": 21,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 11,
"end": 19,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 11,
"end": 17,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 12,
"end": 16,
"ctxt": 0
},
"questionDotToken": {
"start": 13,
"end": 14,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 12,
"end": 16,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 12,
"end": 13,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 18,
"end": 19,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 24,
"end": 39,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 24,
"end": 38,
"ctxt": 0
},
"questionDotToken": {
"start": 35,
"end": 36,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 24,
"end": 38,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 24,
"end": 35,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 24,
"end": 33,
"ctxt": 0
},
"questionDotToken": {
"start": 30,
"end": 31,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 24,
"end": 33,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 24,
"end": 30,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 25,
"end": 29,
"ctxt": 0
},
"questionDotToken": {
"start": 26,
"end": 27,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 25,
"end": 29,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 28,
"end": 29,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 32,
"end": 33,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 34,
"end": 35,
"ctxt": 0
},
"value": "d",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": "e",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,3 @@
a?.b.c.d.e?.f
a.b.c?.d.e.f

View File

@ -0,0 +1,288 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 27,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 13,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 13,
"ctxt": 0
},
"questionDotToken": {
"start": 10,
"end": 11,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 13,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 10,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 8,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 6,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 0,
"end": 4,
"ctxt": 0
},
"questionDotToken": {
"start": 1,
"end": 2,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 4,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 3,
"end": 4,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "d",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 9,
"end": 10,
"ctxt": 0
},
"value": "e",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 12,
"end": 13,
"ctxt": 0
},
"value": "f",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 15,
"end": 27,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 27,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 25,
"ctxt": 0
},
"object": {
"type": "OptionalChainingExpression",
"span": {
"start": 15,
"end": 23,
"ctxt": 0
},
"questionDotToken": {
"start": 20,
"end": 21,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 23,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 20,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 15,
"end": 18,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"value": "a",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 17,
"end": 18,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 19,
"end": 20,
"ctxt": 0
},
"value": "c",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 22,
"end": 23,
"ctxt": 0
},
"value": "d",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 24,
"end": 25,
"ctxt": 0
},
"value": "e",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"property": {
"type": "Identifier",
"span": {
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "f",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
],
"interpreter": null
}

View File

@ -0,0 +1,5 @@
class A extends B {
constructor(){
super()?.b;
}
}

View File

@ -0,0 +1,140 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 66,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "A",
"typeAnnotation": null,
"optional": false
},
"declare": false,
"span": {
"start": 0,
"end": 66,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "Constructor",
"span": {
"start": 24,
"end": 64,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 24,
"end": 35,
"ctxt": 0
},
"value": "constructor",
"typeAnnotation": null,
"optional": false
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 37,
"end": 64,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 47,
"end": 58,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 47,
"end": 57,
"ctxt": 0
},
"questionDotToken": {
"start": 54,
"end": 55,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 47,
"end": 57,
"ctxt": 0
},
"object": {
"type": "CallExpression",
"span": {
"start": 47,
"end": 54,
"ctxt": 0
},
"callee": {
"type": "Super",
"span": {
"start": 47,
"end": 52,
"ctxt": 0
}
},
"arguments": [],
"typeArguments": null
},
"property": {
"type": "Identifier",
"span": {
"start": 56,
"end": 57,
"ctxt": 0
},
"value": "b",
"typeAnnotation": null,
"optional": false
},
"computed": false
}
}
}
]
},
"accessibility": null,
"isOptional": false
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 16,
"end": 17,
"ctxt": 0
},
"value": "B",
"typeAnnotation": null,
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}

View File

@ -27,6 +27,11 @@
"end": 20,
"ctxt": 0
},
"questionDotToken": {
"start": 13,
"end": 14,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_transforms"
version = "0.15.2"
version = "0.16.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"
@ -11,10 +11,10 @@ edition = "2018"
[dependencies]
swc_atoms = { version = "0.2.0", path ="../../atoms" }
swc_common = { version = "0.7.0", path ="../../common" }
swc_ecma_ast = { version = "0.25.0", path ="../ast" }
swc_ecma_utils = { version = "0.14.0", path ="../utils" }
swc_ecma_parser = { version = "0.30.0", path ="../parser" }
swc_ecma_visit = { version = "0.10.0", path ="../visit" }
swc_ecma_ast = { version = "0.26.0", path ="../ast" }
swc_ecma_utils = { version = "0.15.0", path ="../utils" }
swc_ecma_parser = { version = "0.31.0", path ="../parser" }
swc_ecma_visit = { version = "0.11.0", path ="../visit" }
dashmap = "=3.5.1"
either = "1.5"
fxhash = "0.2"
@ -34,7 +34,7 @@ log = "0.4.8"
[dev-dependencies]
testing = { version = "0.7", path ="../../testing" }
swc_ecma_codegen = { version = "0.28.0", path ="../codegen" }
swc_ecma_codegen = { version = "0.29.0", path ="../codegen" }
tempfile = "3"
pretty_assertions = "0.6"
sourcemap = "6"

View File

@ -200,6 +200,7 @@ impl OptChaining {
span: m_span,
}) if obj.is_opt_chain() => {
let obj = obj.opt_chain().unwrap();
let question_dot_token = obj.question_dot_token;
let obj_span = obj.span;
let obj = self.unwrap(obj);
@ -212,6 +213,7 @@ impl OptChaining {
}));
let alt = Box::new(Expr::OptChain(OptChainExpr {
span: obj_span,
question_dot_token,
expr: alt,
}));
@ -225,6 +227,8 @@ impl OptChaining {
type_args,
}) if callee.is_opt_chain() => {
let callee = callee.opt_chain().unwrap();
let question_dot_token = callee.question_dot_token;
let obj = self.unwrap(callee);
let alt = Box::new(Expr::Call(CallExpr {
@ -233,7 +237,11 @@ impl OptChaining {
args,
type_args,
}));
let alt = Box::new(Expr::OptChain(OptChainExpr { span, expr: alt }));
let alt = Box::new(Expr::OptChain(OptChainExpr {
span,
question_dot_token,
expr: alt,
}));
return validate!(CondExpr {
span: DUMMY_SP,

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_utils"
version = "0.14.0"
version = "0.15.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"
@ -11,12 +11,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_ecma_ast = { version = "0.25.0", path ="../ast" }
swc_ecma_ast = { version = "0.26.0", path ="../ast" }
swc_atoms = { version = "0.2.0", path ="../../atoms" }
swc_common = { version = "0.7.0", path ="../../common" }
swc_ecma_parser = { version = "0.30", path ="../parser" }
swc_ecma_visit = { version = "0.10", path ="../visit" }
anyhow = "1.0.26"
swc_ecma_parser = { version = "0.31", path ="../parser" }
swc_ecma_visit = { version = "0.11", path ="../visit" }
once_cell = "1"
scoped-tls = "1"
unicode-xid = "0.2"

View File

@ -29,9 +29,7 @@ mod macros;
pub mod constructor;
mod factory;
pub mod ident;
pub mod load;
pub mod options;
pub mod resolve;
mod value;
pub mod var;

View File

@ -1,20 +0,0 @@
use anyhow::Error;
use std::{path::Path, sync::Arc};
use swc_common::SourceFile;
use swc_ecma_ast::Module;
pub trait Load {
fn load(&self, path: &Path) -> Result<(Arc<SourceFile>, Module), Error>;
}
impl<T: ?Sized + Load> Load for Box<T> {
fn load(&self, path: &Path) -> Result<(Arc<SourceFile>, Module), Error> {
T::load(self, path)
}
}
impl<'a, T: ?Sized + Load> Load for &'a T {
fn load(&self, path: &Path) -> Result<(Arc<SourceFile>, Module), Error> {
T::load(self, path)
}
}

View File

@ -1,20 +0,0 @@
use anyhow::Error;
use std::path::{Path, PathBuf};
pub trait Resolve {
/// Returned filename will be hashed if possible and used to generate module
/// id.
fn resolve(&self, base: &Path, import: &str) -> Result<PathBuf, Error>;
}
impl<T: ?Sized + Resolve> Resolve for Box<T> {
fn resolve(&self, base: &Path, import: &str) -> Result<PathBuf, Error> {
T::resolve(self, base, import)
}
}
impl<'a, T: ?Sized + Resolve> Resolve for &'a T {
fn resolve(&self, base: &Path, import: &str) -> Result<PathBuf, Error> {
T::resolve(self, base, import)
}
}

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_visit"
version = "0.10.0"
version = "0.11.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"
@ -12,6 +12,6 @@ edition = "2018"
[dependencies]
swc_atoms = { version = "0.2", path = "../../atoms" }
swc_common = { version = "0.7", path = "../../common" }
swc_ecma_ast = { version = "0.25.0", path ="../ast" }
swc_ecma_ast = { version = "0.26.0", path ="../ast" }
swc_visit = { version = "0.1", path ="../../visit" }
num-bigint = { version = "0.2", features = ["serde"] }

View File

@ -413,6 +413,7 @@ define!({
}
pub struct OptChainExpr {
pub span: Span,
pub question_dot_token: Span,
pub expr: Box<Expr>,
}
pub struct Function {