diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property-class/input.js b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property-class/input.js new file mode 100644 index 0000000000..7af8cadabc --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property-class/input.js @@ -0,0 +1,5 @@ +class A{ + b(){ + return super?.b; + } +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json new file mode 100644 index 0000000000..0bbb2f11ba --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json @@ -0,0 +1,4 @@ +{ + "plugins":["optionalChaining"], + "throws": "Unexpected token (3:20)" +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property/input.js b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property/input.js new file mode 100644 index 0000000000..dafc54712f --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property/input.js @@ -0,0 +1,5 @@ +const a = { + b(){ + return super?.c; + } +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property/options.json b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property/options.json new file mode 100644 index 0000000000..0bbb2f11ba --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/optional-super-property/options.json @@ -0,0 +1,4 @@ +{ + "plugins":["optionalChaining"], + "throws": "Unexpected token (3:20)" +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/input.js b/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/input.js new file mode 100644 index 0000000000..31dcb716ca --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/input.js @@ -0,0 +1,5 @@ +class A{ + constructor(){ + super()?.b; + } +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/options.json b/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/options.json new file mode 100644 index 0000000000..1655838858 --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/options.json @@ -0,0 +1,3 @@ +{ + "plugins":["optionalChaining"] +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/output.json b/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/output.json new file mode 100644 index 0000000000..b6c5a510c4 --- /dev/null +++ b/packages/babylon/test/fixtures/experimental/optional-chaining/super-method-class/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 7, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 13, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 36, + "end": 47, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "expression": { + "type": "OptionalMemberExpression", + "start": 36, + "end": 46, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "object": { + "type": "CallExpression", + "start": 36, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "callee": { + "type": "Super", + "start": 36, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "arguments": [] + }, + "property": { + "type": "Identifier", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "optional": true + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file