From 177201b11ee098caa090a9a77efd65a5eefda7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 2 Jun 2022 23:31:18 +0200 Subject: [PATCH] [ts] Allow `...<...>` followed by newline and strict keyword --- .../src/plugins/typescript/index.js | 28 +- .../input.ts | 11 + .../options.json | 3 + .../output.json | 185 +++++++ .../input.ts | 35 ++ .../output.json | 484 ++++++++++++++++++ 6 files changed, 735 insertions(+), 11 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/input.ts create mode 100644 packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/input.ts create mode 100644 packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/output.json diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index ab1149dfc028..85235e96ba8c 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -39,6 +39,7 @@ import type { ExpressionErrors } from "../../parser/util"; import { PARAM } from "../../util/production-parameter"; import { Errors, ParseErrorEnum } from "../../parse-error"; import { cloneIdentifier } from "../../parser/node"; +import { isStrictReservedWord } from "../../util/identifier"; const getOwn = (object, key) => Object.hasOwnProperty.call(object, key) && object[key]; @@ -2429,11 +2430,11 @@ export default (superClass: Class): Class => } const typeArguments = this.tsParseTypeArgumentsInExpression(); - if (!typeArguments) throw this.unexpected(); + if (!typeArguments) return; if (isOptionalCall && !this.match(tt.parenL)) { missingParenErrorLoc = this.state.curPosition(); - throw this.unexpected(); + return; } if (tokenIsTemplate(this.state.type)) { @@ -2469,19 +2470,24 @@ export default (superClass: Class): Class => return this.finishCallExpression(node, state.optionalChainMember); } - // TODO: This doesn't exactly match what TS does when it comes to ASI. - // For example, - // a - // if (0); - // is not valid TS code (https://github.com/microsoft/TypeScript/issues/48654) - // However, it should correctly parse anything that is correctly parsed by TS. + const tokenType = this.state.type; if ( - tsTokenCanStartExpression(this.state.type) && - this.state.type !== tt.parenL + tsTokenCanStartExpression(tokenType) && + tokenType !== tt.parenL && + // If the next token is a strict-mode keyword, tsc parses this as an + // instantiation expression to prevent things like + // a = b + // let d; + // from benig parsed as relational expressions. + !( + tokenIsIdentifier(tokenType) && + isStrictReservedWord(this.state.value, true) && + this.hasPrecedingLineBreak() + ) ) { // Bail out. We have something like ac, which is not an expression with // type arguments but an (a < b) > c comparison. - throw this.unexpected(); + return; } const node: N.TsInstantiationExpression = this.startNodeAt( diff --git a/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/input.ts b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/input.ts new file mode 100644 index 000000000000..6a3b96982741 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/input.ts @@ -0,0 +1,11 @@ +a let + +a interface + +async function G() { + a await 0 +} + +a await + +a yield diff --git a/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/options.json b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/options.json new file mode 100644 index 000000000000..b412ffe6712f --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/output.json b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/output.json new file mode 100644 index 000000000000..dfd1ff3fd887 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-no-newline/output.json @@ -0,0 +1,185 @@ +{ + "type": "File", + "start":0,"end":89,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":11,"column":10,"index":89}}, + "program": { + "type": "Program", + "start":0,"end":89,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":11,"column":10,"index":89}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":8,"index":8}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":8,"index":8}}, + "left": { + "type": "BinaryExpression", + "start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":1,"index":1},"identifierName":"a"}, + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":3,"index":3},"identifierName":"b"}, + "name": "b" + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start":5,"end":8,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":8,"index":8},"identifierName":"let"}, + "name": "let" + } + } + }, + { + "type": "ExpressionStatement", + "start":10,"end":24,"loc":{"start":{"line":3,"column":0,"index":10},"end":{"line":3,"column":14,"index":24}}, + "expression": { + "type": "BinaryExpression", + "start":10,"end":24,"loc":{"start":{"line":3,"column":0,"index":10},"end":{"line":3,"column":14,"index":24}}, + "left": { + "type": "BinaryExpression", + "start":10,"end":13,"loc":{"start":{"line":3,"column":0,"index":10},"end":{"line":3,"column":3,"index":13}}, + "left": { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":3,"column":0,"index":10},"end":{"line":3,"column":1,"index":11},"identifierName":"a"}, + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start":12,"end":13,"loc":{"start":{"line":3,"column":2,"index":12},"end":{"line":3,"column":3,"index":13},"identifierName":"b"}, + "name": "b" + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start":15,"end":24,"loc":{"start":{"line":3,"column":5,"index":15},"end":{"line":3,"column":14,"index":24},"identifierName":"interface"}, + "name": "interface" + } + } + }, + { + "type": "FunctionDeclaration", + "start":26,"end":65,"loc":{"start":{"line":5,"column":0,"index":26},"end":{"line":7,"column":1,"index":65}}, + "id": { + "type": "Identifier", + "start":41,"end":42,"loc":{"start":{"line":5,"column":15,"index":41},"end":{"line":5,"column":16,"index":42},"identifierName":"G"}, + "name": "G" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":45,"end":65,"loc":{"start":{"line":5,"column":19,"index":45},"end":{"line":7,"column":1,"index":65}}, + "body": [ + { + "type": "ExpressionStatement", + "start":51,"end":63,"loc":{"start":{"line":6,"column":4,"index":51},"end":{"line":6,"column":16,"index":63}}, + "expression": { + "type": "BinaryExpression", + "start":51,"end":63,"loc":{"start":{"line":6,"column":4,"index":51},"end":{"line":6,"column":16,"index":63}}, + "left": { + "type": "BinaryExpression", + "start":51,"end":54,"loc":{"start":{"line":6,"column":4,"index":51},"end":{"line":6,"column":7,"index":54}}, + "left": { + "type": "Identifier", + "start":51,"end":52,"loc":{"start":{"line":6,"column":4,"index":51},"end":{"line":6,"column":5,"index":52},"identifierName":"a"}, + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start":53,"end":54,"loc":{"start":{"line":6,"column":6,"index":53},"end":{"line":6,"column":7,"index":54},"identifierName":"b"}, + "name": "b" + } + }, + "operator": ">", + "right": { + "type": "AwaitExpression", + "start":56,"end":63,"loc":{"start":{"line":6,"column":9,"index":56},"end":{"line":6,"column":16,"index":63}}, + "argument": { + "type": "NumericLiteral", + "start":62,"end":63,"loc":{"start":{"line":6,"column":15,"index":62},"end":{"line":6,"column":16,"index":63}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + } + ], + "directives": [] + } + }, + { + "type": "ExpressionStatement", + "start":67,"end":77,"loc":{"start":{"line":9,"column":0,"index":67},"end":{"line":9,"column":10,"index":77}}, + "expression": { + "type": "BinaryExpression", + "start":67,"end":77,"loc":{"start":{"line":9,"column":0,"index":67},"end":{"line":9,"column":10,"index":77}}, + "left": { + "type": "BinaryExpression", + "start":67,"end":70,"loc":{"start":{"line":9,"column":0,"index":67},"end":{"line":9,"column":3,"index":70}}, + "left": { + "type": "Identifier", + "start":67,"end":68,"loc":{"start":{"line":9,"column":0,"index":67},"end":{"line":9,"column":1,"index":68},"identifierName":"a"}, + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start":69,"end":70,"loc":{"start":{"line":9,"column":2,"index":69},"end":{"line":9,"column":3,"index":70},"identifierName":"b"}, + "name": "b" + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start":72,"end":77,"loc":{"start":{"line":9,"column":5,"index":72},"end":{"line":9,"column":10,"index":77},"identifierName":"await"}, + "name": "await" + } + } + }, + { + "type": "ExpressionStatement", + "start":79,"end":89,"loc":{"start":{"line":11,"column":0,"index":79},"end":{"line":11,"column":10,"index":89}}, + "expression": { + "type": "BinaryExpression", + "start":79,"end":89,"loc":{"start":{"line":11,"column":0,"index":79},"end":{"line":11,"column":10,"index":89}}, + "left": { + "type": "BinaryExpression", + "start":79,"end":82,"loc":{"start":{"line":11,"column":0,"index":79},"end":{"line":11,"column":3,"index":82}}, + "left": { + "type": "Identifier", + "start":79,"end":80,"loc":{"start":{"line":11,"column":0,"index":79},"end":{"line":11,"column":1,"index":80},"identifierName":"a"}, + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start":81,"end":82,"loc":{"start":{"line":11,"column":2,"index":81},"end":{"line":11,"column":3,"index":82},"identifierName":"b"}, + "name": "b" + } + }, + "operator": ">", + "right": { + "type": "Identifier", + "start":84,"end":89,"loc":{"start":{"line":11,"column":5,"index":84},"end":{"line":11,"column":10,"index":89},"identifierName":"yield"}, + "name": "yield" + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/input.ts b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/input.ts new file mode 100644 index 000000000000..851c1aa3dc80 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/input.ts @@ -0,0 +1,35 @@ +a +let A; + +a +interface B {} + +class C { + _ = a + static __; +} + +class D { + _ = a + public __; +} + +class E { + _ = a + private __; +} + +class F { + _ = a + protected __; +} + +async function G() { + a + await 0 +} + +function* H() { + a + yield 0 +} diff --git a/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/output.json b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/output.json new file mode 100644 index 000000000000..cf733e30287f --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-and-strict-kw-with-newline/output.json @@ -0,0 +1,484 @@ +{ + "type": "File", + "start":0,"end":285,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":35,"column":1,"index":285}}, + "program": { + "type": "Program", + "start":0,"end":285,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":35,"column":1,"index":285}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, + "expression": { + "type": "TSInstantiationExpression", + "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, + "expression": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":1,"index":1},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":1,"end":4,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":4,"index":4}}, + "params": [ + { + "type": "TSTypeReference", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":3,"index":3}}, + "typeName": { + "type": "Identifier", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":3,"index":3},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "VariableDeclaration", + "start":5,"end":11,"loc":{"start":{"line":2,"column":0,"index":5},"end":{"line":2,"column":6,"index":11}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":9,"end":10,"loc":{"start":{"line":2,"column":4,"index":9},"end":{"line":2,"column":5,"index":10}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":2,"column":4,"index":9},"end":{"line":2,"column":5,"index":10},"identifierName":"A"}, + "name": "A" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "ExpressionStatement", + "start":13,"end":17,"loc":{"start":{"line":4,"column":0,"index":13},"end":{"line":4,"column":4,"index":17}}, + "expression": { + "type": "TSInstantiationExpression", + "start":13,"end":17,"loc":{"start":{"line":4,"column":0,"index":13},"end":{"line":4,"column":4,"index":17}}, + "expression": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":4,"column":0,"index":13},"end":{"line":4,"column":1,"index":14},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":14,"end":17,"loc":{"start":{"line":4,"column":1,"index":14},"end":{"line":4,"column":4,"index":17}}, + "params": [ + { + "type": "TSTypeReference", + "start":15,"end":16,"loc":{"start":{"line":4,"column":2,"index":15},"end":{"line":4,"column":3,"index":16}}, + "typeName": { + "type": "Identifier", + "start":15,"end":16,"loc":{"start":{"line":4,"column":2,"index":15},"end":{"line":4,"column":3,"index":16},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "TSInterfaceDeclaration", + "start":18,"end":32,"loc":{"start":{"line":5,"column":0,"index":18},"end":{"line":5,"column":14,"index":32}}, + "id": { + "type": "Identifier", + "start":28,"end":29,"loc":{"start":{"line":5,"column":10,"index":28},"end":{"line":5,"column":11,"index":29},"identifierName":"B"}, + "name": "B" + }, + "body": { + "type": "TSInterfaceBody", + "start":30,"end":32,"loc":{"start":{"line":5,"column":12,"index":30},"end":{"line":5,"column":14,"index":32}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":34,"end":73,"loc":{"start":{"line":7,"column":0,"index":34},"end":{"line":10,"column":1,"index":73}}, + "id": { + "type": "Identifier", + "start":40,"end":41,"loc":{"start":{"line":7,"column":6,"index":40},"end":{"line":7,"column":7,"index":41},"identifierName":"C"}, + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":42,"end":73,"loc":{"start":{"line":7,"column":8,"index":42},"end":{"line":10,"column":1,"index":73}}, + "body": [ + { + "type": "ClassProperty", + "start":48,"end":56,"loc":{"start":{"line":8,"column":4,"index":48},"end":{"line":8,"column":12,"index":56}}, + "static": false, + "key": { + "type": "Identifier", + "start":48,"end":49,"loc":{"start":{"line":8,"column":4,"index":48},"end":{"line":8,"column":5,"index":49},"identifierName":"_"}, + "name": "_" + }, + "computed": false, + "value": { + "type": "TSInstantiationExpression", + "start":52,"end":56,"loc":{"start":{"line":8,"column":8,"index":52},"end":{"line":8,"column":12,"index":56}}, + "expression": { + "type": "Identifier", + "start":52,"end":53,"loc":{"start":{"line":8,"column":8,"index":52},"end":{"line":8,"column":9,"index":53},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":53,"end":56,"loc":{"start":{"line":8,"column":9,"index":53},"end":{"line":8,"column":12,"index":56}}, + "params": [ + { + "type": "TSTypeReference", + "start":54,"end":55,"loc":{"start":{"line":8,"column":10,"index":54},"end":{"line":8,"column":11,"index":55}}, + "typeName": { + "type": "Identifier", + "start":54,"end":55,"loc":{"start":{"line":8,"column":10,"index":54},"end":{"line":8,"column":11,"index":55},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "ClassProperty", + "start":61,"end":71,"loc":{"start":{"line":9,"column":4,"index":61},"end":{"line":9,"column":14,"index":71}}, + "static": true, + "key": { + "type": "Identifier", + "start":68,"end":70,"loc":{"start":{"line":9,"column":11,"index":68},"end":{"line":9,"column":13,"index":70},"identifierName":"__"}, + "name": "__" + }, + "computed": false, + "value": null + } + ] + } + }, + { + "type": "ClassDeclaration", + "start":75,"end":114,"loc":{"start":{"line":12,"column":0,"index":75},"end":{"line":15,"column":1,"index":114}}, + "id": { + "type": "Identifier", + "start":81,"end":82,"loc":{"start":{"line":12,"column":6,"index":81},"end":{"line":12,"column":7,"index":82},"identifierName":"D"}, + "name": "D" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":83,"end":114,"loc":{"start":{"line":12,"column":8,"index":83},"end":{"line":15,"column":1,"index":114}}, + "body": [ + { + "type": "ClassProperty", + "start":89,"end":97,"loc":{"start":{"line":13,"column":4,"index":89},"end":{"line":13,"column":12,"index":97}}, + "static": false, + "key": { + "type": "Identifier", + "start":89,"end":90,"loc":{"start":{"line":13,"column":4,"index":89},"end":{"line":13,"column":5,"index":90},"identifierName":"_"}, + "name": "_" + }, + "computed": false, + "value": { + "type": "TSInstantiationExpression", + "start":93,"end":97,"loc":{"start":{"line":13,"column":8,"index":93},"end":{"line":13,"column":12,"index":97}}, + "expression": { + "type": "Identifier", + "start":93,"end":94,"loc":{"start":{"line":13,"column":8,"index":93},"end":{"line":13,"column":9,"index":94},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":94,"end":97,"loc":{"start":{"line":13,"column":9,"index":94},"end":{"line":13,"column":12,"index":97}}, + "params": [ + { + "type": "TSTypeReference", + "start":95,"end":96,"loc":{"start":{"line":13,"column":10,"index":95},"end":{"line":13,"column":11,"index":96}}, + "typeName": { + "type": "Identifier", + "start":95,"end":96,"loc":{"start":{"line":13,"column":10,"index":95},"end":{"line":13,"column":11,"index":96},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "ClassProperty", + "start":102,"end":112,"loc":{"start":{"line":14,"column":4,"index":102},"end":{"line":14,"column":14,"index":112}}, + "accessibility": "public", + "static": false, + "key": { + "type": "Identifier", + "start":109,"end":111,"loc":{"start":{"line":14,"column":11,"index":109},"end":{"line":14,"column":13,"index":111},"identifierName":"__"}, + "name": "__" + }, + "computed": false, + "value": null + } + ] + } + }, + { + "type": "ClassDeclaration", + "start":116,"end":156,"loc":{"start":{"line":17,"column":0,"index":116},"end":{"line":20,"column":1,"index":156}}, + "id": { + "type": "Identifier", + "start":122,"end":123,"loc":{"start":{"line":17,"column":6,"index":122},"end":{"line":17,"column":7,"index":123},"identifierName":"E"}, + "name": "E" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":124,"end":156,"loc":{"start":{"line":17,"column":8,"index":124},"end":{"line":20,"column":1,"index":156}}, + "body": [ + { + "type": "ClassProperty", + "start":130,"end":138,"loc":{"start":{"line":18,"column":4,"index":130},"end":{"line":18,"column":12,"index":138}}, + "static": false, + "key": { + "type": "Identifier", + "start":130,"end":131,"loc":{"start":{"line":18,"column":4,"index":130},"end":{"line":18,"column":5,"index":131},"identifierName":"_"}, + "name": "_" + }, + "computed": false, + "value": { + "type": "TSInstantiationExpression", + "start":134,"end":138,"loc":{"start":{"line":18,"column":8,"index":134},"end":{"line":18,"column":12,"index":138}}, + "expression": { + "type": "Identifier", + "start":134,"end":135,"loc":{"start":{"line":18,"column":8,"index":134},"end":{"line":18,"column":9,"index":135},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":135,"end":138,"loc":{"start":{"line":18,"column":9,"index":135},"end":{"line":18,"column":12,"index":138}}, + "params": [ + { + "type": "TSTypeReference", + "start":136,"end":137,"loc":{"start":{"line":18,"column":10,"index":136},"end":{"line":18,"column":11,"index":137}}, + "typeName": { + "type": "Identifier", + "start":136,"end":137,"loc":{"start":{"line":18,"column":10,"index":136},"end":{"line":18,"column":11,"index":137},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "ClassProperty", + "start":143,"end":154,"loc":{"start":{"line":19,"column":4,"index":143},"end":{"line":19,"column":15,"index":154}}, + "accessibility": "private", + "static": false, + "key": { + "type": "Identifier", + "start":151,"end":153,"loc":{"start":{"line":19,"column":12,"index":151},"end":{"line":19,"column":14,"index":153},"identifierName":"__"}, + "name": "__" + }, + "computed": false, + "value": null + } + ] + } + }, + { + "type": "ClassDeclaration", + "start":158,"end":200,"loc":{"start":{"line":22,"column":0,"index":158},"end":{"line":25,"column":1,"index":200}}, + "id": { + "type": "Identifier", + "start":164,"end":165,"loc":{"start":{"line":22,"column":6,"index":164},"end":{"line":22,"column":7,"index":165},"identifierName":"F"}, + "name": "F" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":166,"end":200,"loc":{"start":{"line":22,"column":8,"index":166},"end":{"line":25,"column":1,"index":200}}, + "body": [ + { + "type": "ClassProperty", + "start":172,"end":180,"loc":{"start":{"line":23,"column":4,"index":172},"end":{"line":23,"column":12,"index":180}}, + "static": false, + "key": { + "type": "Identifier", + "start":172,"end":173,"loc":{"start":{"line":23,"column":4,"index":172},"end":{"line":23,"column":5,"index":173},"identifierName":"_"}, + "name": "_" + }, + "computed": false, + "value": { + "type": "TSInstantiationExpression", + "start":176,"end":180,"loc":{"start":{"line":23,"column":8,"index":176},"end":{"line":23,"column":12,"index":180}}, + "expression": { + "type": "Identifier", + "start":176,"end":177,"loc":{"start":{"line":23,"column":8,"index":176},"end":{"line":23,"column":9,"index":177},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":177,"end":180,"loc":{"start":{"line":23,"column":9,"index":177},"end":{"line":23,"column":12,"index":180}}, + "params": [ + { + "type": "TSTypeReference", + "start":178,"end":179,"loc":{"start":{"line":23,"column":10,"index":178},"end":{"line":23,"column":11,"index":179}}, + "typeName": { + "type": "Identifier", + "start":178,"end":179,"loc":{"start":{"line":23,"column":10,"index":178},"end":{"line":23,"column":11,"index":179},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "ClassProperty", + "start":185,"end":198,"loc":{"start":{"line":24,"column":4,"index":185},"end":{"line":24,"column":17,"index":198}}, + "accessibility": "protected", + "static": false, + "key": { + "type": "Identifier", + "start":195,"end":197,"loc":{"start":{"line":24,"column":14,"index":195},"end":{"line":24,"column":16,"index":197},"identifierName":"__"}, + "name": "__" + }, + "computed": false, + "value": null + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start":202,"end":245,"loc":{"start":{"line":27,"column":0,"index":202},"end":{"line":30,"column":1,"index":245}}, + "id": { + "type": "Identifier", + "start":217,"end":218,"loc":{"start":{"line":27,"column":15,"index":217},"end":{"line":27,"column":16,"index":218},"identifierName":"G"}, + "name": "G" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":221,"end":245,"loc":{"start":{"line":27,"column":19,"index":221},"end":{"line":30,"column":1,"index":245}}, + "body": [ + { + "type": "ExpressionStatement", + "start":227,"end":231,"loc":{"start":{"line":28,"column":4,"index":227},"end":{"line":28,"column":8,"index":231}}, + "expression": { + "type": "TSInstantiationExpression", + "start":227,"end":231,"loc":{"start":{"line":28,"column":4,"index":227},"end":{"line":28,"column":8,"index":231}}, + "expression": { + "type": "Identifier", + "start":227,"end":228,"loc":{"start":{"line":28,"column":4,"index":227},"end":{"line":28,"column":5,"index":228},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":228,"end":231,"loc":{"start":{"line":28,"column":5,"index":228},"end":{"line":28,"column":8,"index":231}}, + "params": [ + { + "type": "TSTypeReference", + "start":229,"end":230,"loc":{"start":{"line":28,"column":6,"index":229},"end":{"line":28,"column":7,"index":230}}, + "typeName": { + "type": "Identifier", + "start":229,"end":230,"loc":{"start":{"line":28,"column":6,"index":229},"end":{"line":28,"column":7,"index":230},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start":236,"end":243,"loc":{"start":{"line":29,"column":4,"index":236},"end":{"line":29,"column":11,"index":243}}, + "expression": { + "type": "AwaitExpression", + "start":236,"end":243,"loc":{"start":{"line":29,"column":4,"index":236},"end":{"line":29,"column":11,"index":243}}, + "argument": { + "type": "NumericLiteral", + "start":242,"end":243,"loc":{"start":{"line":29,"column":10,"index":242},"end":{"line":29,"column":11,"index":243}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start":247,"end":285,"loc":{"start":{"line":32,"column":0,"index":247},"end":{"line":35,"column":1,"index":285}}, + "id": { + "type": "Identifier", + "start":257,"end":258,"loc":{"start":{"line":32,"column":10,"index":257},"end":{"line":32,"column":11,"index":258},"identifierName":"H"}, + "name": "H" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":261,"end":285,"loc":{"start":{"line":32,"column":14,"index":261},"end":{"line":35,"column":1,"index":285}}, + "body": [ + { + "type": "ExpressionStatement", + "start":267,"end":271,"loc":{"start":{"line":33,"column":4,"index":267},"end":{"line":33,"column":8,"index":271}}, + "expression": { + "type": "TSInstantiationExpression", + "start":267,"end":271,"loc":{"start":{"line":33,"column":4,"index":267},"end":{"line":33,"column":8,"index":271}}, + "expression": { + "type": "Identifier", + "start":267,"end":268,"loc":{"start":{"line":33,"column":4,"index":267},"end":{"line":33,"column":5,"index":268},"identifierName":"a"}, + "name": "a" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":268,"end":271,"loc":{"start":{"line":33,"column":5,"index":268},"end":{"line":33,"column":8,"index":271}}, + "params": [ + { + "type": "TSTypeReference", + "start":269,"end":270,"loc":{"start":{"line":33,"column":6,"index":269},"end":{"line":33,"column":7,"index":270}}, + "typeName": { + "type": "Identifier", + "start":269,"end":270,"loc":{"start":{"line":33,"column":6,"index":269},"end":{"line":33,"column":7,"index":270},"identifierName":"b"}, + "name": "b" + } + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start":276,"end":283,"loc":{"start":{"line":34,"column":4,"index":276},"end":{"line":34,"column":11,"index":283}}, + "expression": { + "type": "YieldExpression", + "start":276,"end":283,"loc":{"start":{"line":34,"column":4,"index":276},"end":{"line":34,"column":11,"index":283}}, + "delegate": false, + "argument": { + "type": "NumericLiteral", + "start":282,"end":283,"loc":{"start":{"line":34,"column":10,"index":282},"end":{"line":34,"column":11,"index":283}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +}