From b0386005c818d308ad0980a4a48042697a5f60ec Mon Sep 17 00:00:00 2001 From: Sven SAULEAU Date: Tue, 30 May 2017 20:14:19 +0200 Subject: [PATCH] docs: NewExpression spec --- ast/spec.md | 1 + .../class-contructor-call/actual.js | 2 + .../class-contructor-call/expected.json | 132 ++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 test/fixtures/experimental/optional-chaining/class-contructor-call/expected.json diff --git a/ast/spec.md b/ast/spec.md index ce24b1e5df..b5d6517184 100644 --- a/ast/spec.md +++ b/ast/spec.md @@ -908,6 +908,7 @@ A function or method call expression. ```js interface NewExpression <: CallExpression { type: "NewExpression"; + optional: boolean | null; } ``` diff --git a/test/fixtures/experimental/optional-chaining/class-contructor-call/actual.js b/test/fixtures/experimental/optional-chaining/class-contructor-call/actual.js index 8e9b00d27f..e08331157e 100644 --- a/test/fixtures/experimental/optional-chaining/class-contructor-call/actual.js +++ b/test/fixtures/experimental/optional-chaining/class-contructor-call/actual.js @@ -1 +1,3 @@ new C?.() + +new C?.(a, b) diff --git a/test/fixtures/experimental/optional-chaining/class-contructor-call/expected.json b/test/fixtures/experimental/optional-chaining/class-contructor-call/expected.json new file mode 100644 index 0000000000..38e9ba308e --- /dev/null +++ b/test/fixtures/experimental/optional-chaining/class-contructor-call/expected.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NewExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "callee": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "C" + }, + "name": "C" + }, + "arguments": [], + "optional": true + } + }, + { + "type": "ExpressionStatement", + "start": 11, + "end": 24, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "expression": { + "type": "NewExpression", + "start": 11, + "end": 24, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "callee": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "C" + }, + "name": "C" + }, + "arguments": [], + "optional": true + } + } + ], + "directives": [] + } +}