diff --git a/lib/acorn/AUTHORS b/vendor/acorn/AUTHORS similarity index 100% rename from lib/acorn/AUTHORS rename to vendor/acorn/AUTHORS diff --git a/lib/acorn/LICENSE b/vendor/acorn/LICENSE similarity index 100% rename from lib/acorn/LICENSE rename to vendor/acorn/LICENSE diff --git a/lib/acorn/README.md b/vendor/acorn/README.md similarity index 100% rename from lib/acorn/README.md rename to vendor/acorn/README.md diff --git a/lib/acorn/acorn.js b/vendor/acorn/acorn.js similarity index 93% rename from lib/acorn/acorn.js rename to vendor/acorn/acorn.js index 16e07ab099..4e0ceb83f0 100644 --- a/lib/acorn/acorn.js +++ b/vendor/acorn/acorn.js @@ -122,7 +122,7 @@ preserveParens: false, plugins: {}, // Babel-specific options - transformers: {}, + features: {}, strictMode: false }; @@ -911,7 +911,7 @@ var width = 1; var next = this.input.charCodeAt(this.pos + 1); - if (this.options.transformers["es7.exponentiationOperator"] && next === 42) { // '*' + if (next === 42) { // '*' width++; next = this.input.charCodeAt(this.pos + 2); type = tt.exponent; @@ -1838,6 +1838,17 @@ this.raise(this.start, "'import' and 'export' may only appear at the top level"); return starttype === tt._import ? this.parseImport(node) : this.parseExport(node); + case tt.name: + if (this.options.features["es7.asyncFunctions"] && this.value === "async") { + // check to see if `function ` appears after this token, this is + // pretty hacky + if (this.input.slice(this.pos + 1, this.pos + 10) === "function ") { + this.next(); + this.expect(tt._function); + return this.parseFunction(node, true, false, true); + } + } + // If the statement does not start with a statement keyword or a // brace, it's an ExpressionStatement or LabeledStatement. We // simply start parsing an expression, and afterwards, if the @@ -2346,8 +2357,51 @@ if (this.inGenerator) unexpected(); case tt.name: + if (this.value === "super") { + var node = this.startNode(); + this.next(); + return this.finishNode(node, "SuperExpression"); + } + var start = this.currentPos(); + var node = this.startNode(); var id = this.parseIdent(this.type !== tt.name); + + // + if (this.options.features["es7.asyncFunctions"]) { + // async functions! + if (id.name === "async") { + // arrow functions + if (this.type === tt.parenL) { + var expr = this.parseParenAndDistinguishExpression(start, true); + if (expr.type === "ArrowFunctionExpression") { + return expr; + } else { + node.callee = id; + if (expr.type === "SequenceExpression") { + node.arguments = expr.expressions; + } else { + node.arguments = [expr]; + } + return this.parseSubscripts(this.finishNode(node, "CallExpression"), start); + } + } else if (this.type === tt.name) { + id = this.parseIdent(); + this.expect(tt.arrow); + return this.parseArrowExpression(node, [id], true); + } + + // normal functions + if (this.type === tt._function && !this.canInsertSemicolon()) { + this.next(); + return this.parseFunction(node, false, false, true); + } + } else if (id.name === "await") { + if (this.inAsync) return this.parseAwait(node); + } + } + // + if (!this.canInsertSemicolon() && this.eat(tt.arrow)) { return this.parseArrowExpression(this.startNodeAt(start), [id]); } @@ -2376,7 +2430,7 @@ var node = this.startNode(); this.next(); // check whether this is array comprehension or regular array - if (this.options.transformers["es7.comprehensions"] && this.type === tt._for) { + if ((this.options.features["es7.comprehensions"] || this.options.ecmaVersion >= 7) && this.type === tt._for) { return this.parseComprehension(node, false); } node.elements = this.parseExprList(tt.bracketR, true, true, refShorthandDefaultPos); @@ -2412,12 +2466,13 @@ return this.finishNode(node, "Literal"); }; - pp.parseParenAndDistinguishExpression = function() { - var start = this.currentPos(), val; + pp.parseParenAndDistinguishExpression = function(start, isAsync) { + start = start || this.currentPos(); + var val; if (this.options.ecmaVersion >= 6) { this.next(); - if (this.options.transformers["es7.comprehensions"] && this.type === tt._for) { + if ((this.options.features["es7.comprehensions"] || this.options.ecmaVersion >= 7) && this.type === tt._for) { return this.parseComprehension(this.startNodeAt(start), true); } @@ -2442,7 +2497,7 @@ if (!this.canInsertSemicolon() && this.eat(tt.arrow)) { if (innerParenStart) this.unexpected(innerParenStart); - return this.parseArrowExpression(this.startNodeAt(start), exprList); + return this.parseParenArrowList(start, exprList, isAsync); } if (!exprList.length) this.unexpected(this.lastTokStart); @@ -2469,6 +2524,10 @@ } }; + pp.parseParenArrowList = function (start, exprList, isAsync) { + return this.parseArrowExpression(this.startNodeAt(start), exprList, isAsync); + }; + pp.parseParenItem = function (node, start) { return node; }; @@ -2528,8 +2587,8 @@ if (this.afterTrailingComma(tt.braceR)) break; } else first = false; - var prop = this.startNode(), isGenerator, start; - if (this.options.transformers["es7.objectRestSpread"] && this.type === tt.ellipsis) { + var prop = this.startNode(), isGenerator, isAsync, start; + if (this.options.features["es7.objectRestSpread"] && this.type === tt.ellipsis) { prop = this.parseSpread(); prop.type = "SpreadProperty"; node.properties.push(prop); @@ -2545,47 +2604,62 @@ isGenerator = this.eat(tt.star); } } - this.parsePropertyName(prop); - if (this.eat(tt.colon)) { - prop.value = isPattern ? this.parseMaybeDefault() : this.parseMaybeAssign(false, refShorthandDefaultPos); - prop.kind = "init"; - } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) { - if (isPattern) this.unexpected(); - prop.kind = "init"; - prop.method = true; - prop.value = this.parseMethod(isGenerator); - } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && - (prop.key.name === "get" || prop.key.name === "set") && - (this.type != tt.comma && this.type != tt.braceR)) { + if (this.options.features["es7.asyncFunctions"] && this.isContextual("async")) { if (isGenerator || isPattern) this.unexpected(); - prop.kind = prop.key.name; - this.parsePropertyName(prop); - prop.value = this.parseMethod(false); - } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { - prop.kind = "init"; - if (isPattern) { - prop.value = this.parseMaybeDefault(start, prop.key); - } else if (this.type === tt.eq && refShorthandDefaultPos) { - if (!refShorthandDefaultPos.start) - refShorthandDefaultPos.start = this.start; - prop.value = this.parseMaybeDefault(start, prop.key); - } else { - prop.value = prop.key; - } - prop.shorthand = true; - } else this.unexpected(); + var asyncId = this.parseIdent(); + if (this.type === tt.colon || this.type === tt.parenL) { + prop.key = asyncId; + } else { + isAsync = true; + this.parsePropertyName(prop); + } + } else { + this.parsePropertyName(prop); + } + this.parseObjPropValue(prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos); this.checkPropClash(prop, propHash); node.properties.push(this.finishNode(prop, "Property")); } return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression"); }; + pp.parseObjPropValue = function (prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos) { + if (this.eat(tt.colon)) { + prop.value = isPattern ? this.parseMaybeDefault() : this.parseMaybeAssign(false, refShorthandDefaultPos); + prop.kind = "init"; + } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) { + if (isPattern) this.unexpected(); + prop.kind = "init"; + prop.method = true; + prop.value = this.parseMethod(isGenerator, isAsync); + } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && + (prop.key.name === "get" || prop.key.name === "set") && + (this.type != tt.comma && this.type != tt.braceR)) { + if (isGenerator || isAsync || isPattern) this.unexpected(); + prop.kind = prop.key.name; + this.parsePropertyName(prop); + prop.value = this.parseMethod(false); + } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { + prop.kind = "init"; + if (isPattern) { + prop.value = this.parseMaybeDefault(start, prop.key); + } else if (this.type === tt.eq && refShorthandDefaultPos) { + if (!refShorthandDefaultPos.start) + refShorthandDefaultPos.start = this.start; + prop.value = this.parseMaybeDefault(start, prop.key); + } else { + prop.value = prop.key; + } + prop.shorthand = true; + } else this.unexpected(); + }; + pp.parsePropertyName = function(prop) { if (this.options.ecmaVersion >= 6) { if (this.eat(tt.bracketL)) { prop.computed = true; - prop.key = this.parseExpression(); + prop.key = this.parseMaybeAssign(); this.expect(tt.bracketR); return; } else { @@ -2597,19 +2671,22 @@ // Initialize empty function node. - pp.initFunction = function(node) { + pp.initFunction = function(node, isAsync) { node.id = null; if (this.options.ecmaVersion >= 6) { node.generator = false; node.expression = false; } + if (this.options.features["es7.asyncFunctions"]) { + node.async = !!isAsync; + } }; // Parse a function declaration or literal (depending on the // `isStatement` parameter). - pp.parseFunction = function(node, isStatement, allowExpressionBody) { - this.initFunction(node); + pp.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { + this.initFunction(node, isAsync); if (this.options.ecmaVersion >= 6) { node.generator = this.eat(tt.star); } @@ -2628,9 +2705,9 @@ // Parse object or class method. - pp.parseMethod = function(isGenerator) { + pp.parseMethod = function(isGenerator, isAsync) { var node = this.startNode(); - this.initFunction(node); + this.initFunction(node, isAsync); this.expect(tt.parenL); node.params = this.parseBindingList(tt.parenR, false, false); var allowExpressionBody; @@ -2646,8 +2723,8 @@ // Parse arrow function expression with given parameters. - pp.parseArrowExpression = function(node, params) { - this.initFunction(node); + pp.parseArrowExpression = function(node, params, isAsync) { + this.initFunction(node, isAsync); node.params = this.toAssignableList(params, true); this.parseFunctionBody(node, true); return this.finishNode(node, "ArrowFunctionExpression"); @@ -2658,6 +2735,8 @@ pp.parseFunctionBody = function(node, allowExpression) { var isExpression = allowExpression && this.type !== tt.braceL; + var oldInAsync = this.inAsync; + this.inAsync = node.async; if (isExpression) { node.body = this.parseMaybeAssign(); node.expression = true; @@ -2670,6 +2749,7 @@ node.expression = false; this.inFunction = oldInFunc; this.inGenerator = oldInGen; this.labels = oldLabels; } + this.inAsync = oldInAsync; // If this is a strict mode function, verify that argument names // are not repeated, and it does not try to bind the words `eval` @@ -2696,7 +2776,7 @@ while (!this.eat(tt.braceR)) { if (this.eat(tt.semi)) continue; var method = this.startNode(); - var isGenerator = this.eat(tt.star); + var isGenerator = this.eat(tt.star), isAsync; this.parsePropertyName(method); if (this.type !== tt.parenL && !method.computed && method.key.type === "Identifier" && method.key.name === "static") { @@ -2707,21 +2787,35 @@ } else { method['static'] = false; } - if (this.type !== tt.parenL && !method.computed && method.key.type === "Identifier" && - (method.key.name === "get" || method.key.name === "set")) { - if (isGenerator) this.unexpected(); - method.kind = method.key.name; + if (this.options.features["es7.asyncFunctions"] && this.type !== tt.parenL && + !method.computed && method.key.type === "Identifier" && method.key.name === "async") { + isAsync = true; this.parsePropertyName(method); - } else { - method.kind = ""; } - method.value = this.parseMethod(isGenerator); - classBody.body.push(this.finishNode(method, "MethodDefinition")); + method.kind = "method"; + if (!method.computed && !isGenerator) { + if (method.key.type === "Identifier") { + if (this.type !== tt.parenL && (method.key.name === "get" || method.key.name === "set")) { + method.kind = method.key.name; + this.parsePropertyName(method); + } else if (!method['static'] && method.key.name === "constructor") { + method.kind = "constructor"; + } + } else if (!method['static'] && method.key.type === "Literal" && method.key.value === "constructor") { + method.kind = "constructor"; + } + } + this.parseClassMethod(classBody, method, isGenerator, isAsync); } node.body = this.finishNode(classBody, "ClassBody"); return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression"); }; + pp.parseClassMethod = function (classBody, method, isGenerator, isAsync) { + method.value = this.parseMethod(isGenerator, isAsync); + classBody.body.push(this.finishNode(method, "MethodDefinition")); + }; + pp.parseClassId = function (node, isStatement) { node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null; }; @@ -2788,6 +2882,7 @@ if (this.eat(tt.star)) { this.expectContextual("from"); node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected(); + this.semicolon(); return this.finishNode(node, "ExportAllDeclaration"); } if (this.eat(tt._default)) { // export default ...; @@ -2803,7 +2898,7 @@ return this.finishNode(node, "ExportDefaultDeclaration"); } // export var|const|let|function|class ...; - if (this.type.keyword) { + if (this.type.keyword || (this.options.features["es7.asyncFunctions"] && this.isContextual("async"))) { node.declaration = this.parseStatement(true); node.specifiers = []; node.source = null; @@ -2844,13 +2939,13 @@ pp.parseImport = function(node) { this.next(); + node.specifiers = []; // import '...'; if (this.type === tt.string) { - node.specifiers = []; node.source = this.parseExprAtom(); node.kind = ""; } else { - node.specifiers = this.parseImportSpecifiers(); + this.parseImportSpecifiers(node); this.expectContextual("from"); node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected(); } @@ -2860,24 +2955,22 @@ // Parses a comma-separated list of module imports. - pp.parseImportSpecifiers = function() { - var nodes = [], first = true; + pp.parseImportSpecifiers = function(node) { + var first = true; if (this.type === tt.name) { // import defaultObj, { x, y as z } from '...' - var node = this.startNode(); - node.local = this.parseIdent(); - this.checkLVal(node.local, true); - nodes.push(this.finishNode(node, "ImportDefaultSpecifier")); - if (!this.eat(tt.comma)) return nodes; + var start = this.currentPos(); + node.specifiers.push(this.parseImportSpecifierDefault(this.parseIdent(), start)); + if (!this.eat(tt.comma)) return; } if (this.type === tt.star) { - var node = this.startNode(); + var specifier = this.startNode(); this.next(); this.expectContextual("as"); - node.local = this.parseIdent(); - this.checkLVal(node.local, true); - nodes.push(this.finishNode(node, "ImportNamespaceSpecifier")); - return nodes; + specifier.local = this.parseIdent(); + this.checkLVal(specifier.local, true); + node.specifiers.push(this.finishNode(specifier, "ImportNamespaceSpecifier")); + return; } this.expect(tt.braceL); while (!this.eat(tt.braceR)) { @@ -2886,13 +2979,19 @@ if (this.afterTrailingComma(tt.braceR)) break; } else first = false; - var node = this.startNode(); - node.imported = this.parseIdent(true); - node.local = this.eatContextual("as") ? this.parseIdent() : node.imported; - this.checkLVal(node.local, true); - nodes.push(this.finishNode(node, "ImportSpecifier")); + var specifier = this.startNode(); + specifier.imported = this.parseIdent(true); + specifier.local = this.eatContextual("as") ? this.parseIdent() : specifier.imported; + this.checkLVal(specifier.local, true); + node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); } - return nodes; + }; + + pp.parseImportSpecifierDefault = function (id, start) { + var node = this.startNodeAt(start); + node.local = id; + this.checkLVal(node.local, true); + return this.finishNode(node, "ImportDefaultSpecifier"); }; // Parses yield expression inside generator. @@ -2910,6 +3009,17 @@ return this.finishNode(node, "YieldExpression"); }; + // Parses await expression inside async function. + + pp.parseAwait = function (node) { + if (this.eat(tt.semi) || this.canInsertSemicolon()) { + this.unexpected(); + } + node.all = this.eat(tt.star); + node.argument = this.parseMaybeAssign(true); + return this.finishNode(node, "AwaitExpression"); + }; + // Parses array and generator comprehensions. pp.parseComprehension = function(node, isGenerator) { @@ -2931,4 +3041,9 @@ node.generator = isGenerator; return this.finishNode(node, "ComprehensionExpression"); }; + + // init plugins + + require("./plugins/flow"); + require("./plugins/jsx"); }); diff --git a/lib/acorn/package.json b/vendor/acorn/package.json similarity index 100% rename from lib/acorn/package.json rename to vendor/acorn/package.json diff --git a/src/babel/parser/flow.js b/vendor/acorn/plugins/flow.js similarity index 88% rename from src/babel/parser/flow.js rename to vendor/acorn/plugins/flow.js index 052a734158..518dd53c39 100644 --- a/src/babel/parser/flow.js +++ b/vendor/acorn/plugins/flow.js @@ -1,4 +1,4 @@ -import acorn from "../../acorn"; +var acorn = require("../acorn"); var pp = acorn.Parser.prototype; var tt = acorn.tokTypes; @@ -669,6 +669,54 @@ acorn.plugins.flow = function (instance) { }; }); + instance.extend("readToken", function(inner) { + return function(code) { + if (this.inType && (code === 62 || code === 60)) { + return this.finishOp(tt.relational, 1); + } else { + return inner.call(this, code); + } + }; + }); + + instance.extend("parseParenArrowList", function (inner) { + return function (start, exprList, isAsync) { + for (var i = 0; i < exprList.length; i++) { + var listItem = exprList[i]; + if (listItem.type === "TypeCastExpression") { + var expr = listItem.expression; + expr.typeAnnotation = listItem.typeAnnotation; + exprList[i] = expr; + } + } + return inner.call(this, start, exprList, isAsync); + }; + }); + + instance.extend("parseClassMethod", function (inner) { + return function (classBody, method, isGenerator, isAsync) { + var classProperty = false; + + if (this.type === tt.colon) { + method.typeAnnotation = this.flow_parseTypeAnnotation(); + classProperty = true; + } + + if (classProperty) { + this.semicolon(); + classBody.body.push(this.finishNode(method, "ClassProperty")); + } else { + var typeParameters; + if (this.isRelational("<")) { + typeParameters = this.flow_parseTypeParameterDeclaration(); + } + method.value = this.parseMethod(isGenerator, isAsync); + method.value.typeParameters = typeParameters; + classBody.body.push(this.finishNode(method, "MethodDefinition")); + } + }; + }); + instance.extend("parseClassSuper", function (inner) { return function (node, isStatement) { inner.call(this, node, isStatement); @@ -692,6 +740,18 @@ acorn.plugins.flow = function (instance) { }; }); + instance.extend("parseObjPropValue", function (inner) { + return function (prop) { + var typeParameters; + if (this.isRelational("<")) { + typeParameters = this.flow_parseTypeParameterDeclaration(); + if (this.type !== tt.parenL) this.unexpected(); + } + inner.apply(this, arguments); + prop.value.typeParameters = typeParameters; + }; + }); + instance.extend("parseAssignableListItemTypes", function (inner) { return function (param) { if (this.eat(tt.question)) { @@ -705,6 +765,24 @@ acorn.plugins.flow = function (instance) { }; }); + instance.extend("parseImportSpecifiers", function (inner) { + return function (node) { + node.isType = false; + if (this.isContextual("type")) { + var start = this.currentPos(); + var typeId = this.parseIdent(); + if ((this.type === tt.name && this.value !== "from") || this.type === tt.braceL || this.type === tt.star) { + node.isType = true; + } else { + node.specifiers.push(this.parseImportSpecifierDefault(typeId, start)); + if (this.isContextual("from")) return; + this.eat(tt.comma); + } + } + inner.call(this, node); + }; + }); + // function foo() {} instance.extend("parseFunctionParams", function (inner) { return function (node) { diff --git a/src/babel/parser/jsx.js b/vendor/acorn/plugins/jsx.js similarity index 96% rename from src/babel/parser/jsx.js rename to vendor/acorn/plugins/jsx.js index 37d96b33b3..46ac92bf55 100644 --- a/src/babel/parser/jsx.js +++ b/vendor/acorn/plugins/jsx.js @@ -1,4 +1,4 @@ -import acorn from "../../acorn"; +var acorn = require("../acorn"); var tt = acorn.tokTypes; var tc = acorn.tokContexts; @@ -614,26 +614,29 @@ acorn.plugins.jsx = function(instance) { instance.extend("readToken", function(inner) { return function(code) { - var context = this.curContext(); + if (!this.inType) { + var context = this.curContext(); - if (context === tc.j_expr) return this.jsx_readToken(); + if (context === tc.j_expr) return this.jsx_readToken(); - if (context === tc.j_oTag || context === tc.j_cTag) { - if (acorn.isIdentifierStart(code)) return this.jsx_readWord(); + if (context === tc.j_oTag || context === tc.j_cTag) { + if (acorn.isIdentifierStart(code)) return this.jsx_readWord(); - if (code == 62) { - ++this.pos; - return this.finishToken(tt.jsxTagEnd); + if (code == 62) { + ++this.pos; + return this.finishToken(tt.jsxTagEnd); + } + + if ((code === 34 || code === 39) && context == tc.j_oTag) + return this.jsx_readString(code); } - if ((code === 34 || code === 39) && context == tc.j_oTag) - return this.jsx_readString(code); + if (code === 60 && this.exprAllowed) { + ++this.pos; + return this.finishToken(tt.jsxTagStart); + } } - if (code === 60 && this.exprAllowed) { - ++this.pos; - return this.finishToken(tt.jsxTagStart); - } return inner.call(this, code); }; }); diff --git a/lib/acorn/test/bench.html b/vendor/acorn/test/bench.html similarity index 100% rename from lib/acorn/test/bench.html rename to vendor/acorn/test/bench.html diff --git a/lib/acorn/test/codemirror-string.js b/vendor/acorn/test/codemirror-string.js similarity index 100% rename from lib/acorn/test/codemirror-string.js rename to vendor/acorn/test/codemirror-string.js diff --git a/lib/acorn/test/compare/esprima.js b/vendor/acorn/test/compare/esprima.js similarity index 100% rename from lib/acorn/test/compare/esprima.js rename to vendor/acorn/test/compare/esprima.js diff --git a/lib/acorn/test/compare/traceur.js b/vendor/acorn/test/compare/traceur.js similarity index 100% rename from lib/acorn/test/compare/traceur.js rename to vendor/acorn/test/compare/traceur.js diff --git a/lib/acorn/test/driver.js b/vendor/acorn/test/driver.js similarity index 98% rename from lib/acorn/test/driver.js rename to vendor/acorn/test/driver.js index d8998b930b..def4182f97 100644 --- a/lib/acorn/test/driver.js +++ b/vendor/acorn/test/driver.js @@ -33,7 +33,7 @@ else callback("fail", test.code, "Expected error message: " + test.error + "\nGot error message: " + e.message); } else { - callback("error", test.code, e.message || e.toString()); + callback("error", test.code, e.stack || e.toString()); } continue } diff --git a/lib/acorn/test/index.html b/vendor/acorn/test/index.html similarity index 100% rename from lib/acorn/test/index.html rename to vendor/acorn/test/index.html diff --git a/lib/acorn/test/jquery-string.js b/vendor/acorn/test/jquery-string.js similarity index 100% rename from lib/acorn/test/jquery-string.js rename to vendor/acorn/test/jquery-string.js diff --git a/lib/acorn/test/run.js b/vendor/acorn/test/run.js similarity index 87% rename from lib/acorn/test/run.js rename to vendor/acorn/test/run.js index 04f752dc3b..06c809e52f 100644 --- a/lib/acorn/test/run.js +++ b/vendor/acorn/test/run.js @@ -5,6 +5,9 @@ driver = require("./driver.js"); require("./tests.js"); require("./tests-harmony.js"); + require("./tests-flow.js"); + require("./tests-babel.js"); + require("./tests-jsx.js"); } else { driver = window; } @@ -49,17 +52,6 @@ config: { parse: (typeof require === "undefined" ? window.acorn : require("../acorn.js")).parse } - }, - Loose: { - config: { - parse: (typeof require === "undefined" ? window.acorn : require("../acorn_loose")).parse_dammit, - loose: true, - filter: function (test) { - var opts = test.options || {}; - if (opts.loose === false) return false; - return (opts.ecmaVersion || 5) <= 6; - } - } } }; diff --git a/vendor/acorn/test/tests-babel.js b/vendor/acorn/test/tests-babel.js new file mode 100644 index 0000000000..119704ab5e --- /dev/null +++ b/vendor/acorn/test/tests-babel.js @@ -0,0 +1,2057 @@ +var test = require("./driver.js").test; +var testFail = require("./driver.js").testFail; +var testAssert = require("./driver.js").testAssert; + +// ES7: Exponentiation Operator + +test('a **= 2;', { + type: "Program", + start: 0, + end: 8, + body: [{ + type: "ExpressionStatement", + start: 0, + end: 8, + expression: { + type: "AssignmentExpression", + start: 0, + end: 7, + operator: "**=", + left: { + type: "Identifier", + start: 0, + end: 1, + name: "a" + }, + right: { + type: "Literal", + start: 6, + end: 7, + value: 2 + } + } + }] +}, { + ecmaVersion: 7 +}); + +test('var squared = 2 ** 2;', { + type: "Program", + start: 0, + end: 21, + body: [{ + type: "VariableDeclaration", + start: 0, + end: 21, + declarations: [{ + type: "VariableDeclarator", + start: 4, + end: 20, + id: { + type: "Identifier", + start: 4, + end: 11, + name: "squared" + }, + init: { + type: "BinaryExpression", + start: 14, + end: 20, + left: { + type: "Literal", + start: 14, + end: 15, + value: 2 + }, + operator: "**", + right: { + type: "Literal", + start: 19, + end: 20, + value: 2 + } + } + }], + kind: "var" + }] +}, { + ecmaVersion: 7 +}); + +test("2 ** (3 ** 2)", { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "BinaryExpression", + left: { + type: "Literal", + value: 2 + }, + operator: "**", + right: { + type: "BinaryExpression", + left: { + type: "Literal", + value: 3 + }, + operator: "**", + right: { + type: "Literal", + value: 2 + } + } + } + }] +}, { + ecmaVersion: 7 +}); + +test("2 ** 3 ** 2", { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "BinaryExpression", + left: { + type: "Literal", + value: 2 + }, + operator: "**", + right: { + type: "BinaryExpression", + left: { + type: "Literal", + value: 3 + }, + operator: "**", + right: { + type: "Literal", + value: 2 + } + } + } + }] +}, { + ecmaVersion: 7 +}); + +test("(2 ** -1) * 2", { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "BinaryExpression", + left: { + type: "BinaryExpression", + left: { + type: "Literal", + value: 2 + }, + operator: "**", + right: { + type: "UnaryExpression", + operator: "-", + prefix: true, + argument: { + type: "Literal", + value: 1 + } + } + }, + operator: "*", + right: { + type: "Literal", + value: 2 + } + } + }] +}, { + ecmaVersion: 7 +}); + +test("2 ** -1 * 2", { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "BinaryExpression", + left: { + type: "BinaryExpression", + left: { + type: "Literal", + value: 2 + }, + operator: "**", + right: { + type: "UnaryExpression", + operator: "-", + prefix: true, + argument: { + type: "Literal", + value: 1 + } + } + }, + operator: "*", + right: { + type: "Literal", + value: 2 + } + } + }] +}, { + ecmaVersion: 7 +}); + +// ES7: Object Rest/Spread + +test('let {...x} = z', { + type: "Program", + start: 0, + end: 14, + body: [{ + type: "VariableDeclaration", + start: 0, + end: 14, + declarations: [ + { + type: "VariableDeclarator", + start: 4, + end: 14, + id: { + type: "ObjectPattern", + start: 4, + end: 10, + properties: [ + { + type: "SpreadProperty", + start: 5, + end: 9, + argument: { + type: "Identifier", + start: 8, + end: 9, + name: "x" + } + } + ] + }, + init: { + type: "Identifier", + start: 13, + end: 14, + name: "z" + } + } + ], + kind: "let" + }] +}, { + ecmaVersion: 7, + features: { "es7.objectRestSpread": true } +}); + +test('let {x, ...y} = z', { + type: "Program", + start: 0, + end: 17, + body: [{ + type: "VariableDeclaration", + start: 0, + end: 17, + declarations: [ + { + type: "VariableDeclarator", + start: 4, + end: 17, + id: { + type: "ObjectPattern", + start: 4, + end: 13, + properties: [ + { + type: "Property", + start: 5, + end: 6, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 5, + end: 6, + name: "x" + }, + kind: "init", + value: { + type: "Identifier", + start: 5, + end: 6, + name: "x" + } + }, + { + type: "SpreadProperty", + start: 8, + end: 12, + argument: { + type: "Identifier", + start: 11, + end: 12, + name: "y" + } + } + ] + }, + init: { + type: "Identifier", + start: 16, + end: 17, + name: "z" + } + } + ], + kind: "let" + }] +}, { + ecmaVersion: 7, + features: { "es7.objectRestSpread": true } +}); + +test('(function({x, ...y}) { })', { + type: "Program", + start: 0, + end: 25, + body: [{ + type: "ExpressionStatement", + start: 0, + end: 25, + expression: { + type: "FunctionExpression", + start: 1, + end: 24, + id: null, + params: [ + { + type: "ObjectPattern", + start: 10, + end: 19, + properties: [ + { + type: "Property", + start: 11, + end: 12, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 11, + end: 12, + name: "x" + }, + kind: "init", + value: { + type: "Identifier", + start: 11, + end: 12, + name: "x" + } + }, + { + type: "SpreadProperty", + start: 14, + end: 18, + argument: { + type: "Identifier", + start: 17, + end: 18, + name: "y" + } + } + ] + } + ], + generator: false, + body: { + type: "BlockStatement", + start: 21, + end: 24, + body: [] + }, + expression: false + } + }] +}, { + ecmaVersion: 7, + features: { "es7.objectRestSpread": true } +}); + +test('let z = {...x}', { + type: "Program", + start: 0, + end: 14, + body: [{ + type: "VariableDeclaration", + start: 0, + end: 14, + declarations: [ + { + type: "VariableDeclarator", + start: 4, + end: 14, + id: { + type: "Identifier", + start: 4, + end: 5, + name: "z" + }, + init: { + type: "ObjectExpression", + start: 8, + end: 14, + properties: [ + { + type: "SpreadProperty", + start: 9, + end: 13, + argument: { + type: "Identifier", + start: 12, + end: 13, + name: "x" + } + } + ] + } + } + ], + kind: "let" + }] +}, { + ecmaVersion: 7, + features: { "es7.objectRestSpread": true } +}); + +test('z = {x, ...y}', { + type: "Program", + start: 0, + end: 13, + body: [{ + type: "ExpressionStatement", + start: 0, + end: 13, + expression: { + type: "AssignmentExpression", + start: 0, + end: 13, + operator: "=", + left: { + type: "Identifier", + start: 0, + end: 1, + name: "z" + }, + right: { + type: "ObjectExpression", + start: 4, + end: 13, + properties: [ + { + type: "Property", + start: 5, + end: 6, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 5, + end: 6, + name: "x" + }, + kind: "init", + value: { + type: "Identifier", + start: 5, + end: 6, + name: "x" + } + }, + { + type: "SpreadProperty", + start: 8, + end: 12, + argument: { + type: "Identifier", + start: 11, + end: 12, + name: "y" + } + } + ] + } + } + }] +}, { + ecmaVersion: 7, + features: { "es7.objectRestSpread": true } +}); + +test('({x, ...y, a, ...b, c})', { + type: "Program", + start: 0, + end: 23, + body: [{ + type: "ExpressionStatement", + start: 0, + end: 23, + expression: { + type: "ObjectExpression", + start: 1, + end: 22, + properties: [ + { + type: "Property", + start: 2, + end: 3, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 2, + end: 3, + name: "x" + }, + kind: "init", + value: { + type: "Identifier", + start: 2, + end: 3, + name: "x" + } + }, + { + type: "SpreadProperty", + start: 5, + end: 9, + argument: { + type: "Identifier", + start: 8, + end: 9, + name: "y" + } + }, + { + type: "Property", + start: 11, + end: 12, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 11, + end: 12, + name: "a" + }, + kind: "init", + value: { + type: "Identifier", + start: 11, + end: 12, + name: "a" + } + }, + { + type: "SpreadProperty", + start: 14, + end: 18, + argument: { + type: "Identifier", + start: 17, + end: 18, + name: "b" + } + }, + { + type: "Property", + start: 20, + end: 21, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 20, + end: 21, + name: "c" + }, + kind: "init", + value: { + type: "Identifier", + start: 20, + end: 21, + name: "c" + } + } + ] + } + }] +}, { + ecmaVersion: 7, + features: { "es7.objectRestSpread": true } +}); + +// ES7: Async Functions + +testFail("function foo(promise) { await promise; }", "Unexpected token (1:30)", { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true } +}); + +test('async function foo(promise) { await promise; }', { + type: "Program", + body: [{ + type: "FunctionDeclaration", + id: { + type: "Identifier", + name: "foo", + loc: { + start: {line: 1, column: 15}, + end: {line: 1, column: 18} + } + }, + params: [{ + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 19}, + end: {line: 1, column: 26} + } + }], + body: { + type: "BlockStatement", + body: [{ + type: "ExpressionStatement", + expression: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 36}, + end: {line: 1, column: 43} + } + }, + loc: { + start: {line: 1, column: 30}, + end: {line: 1, column: 43} + } + }, + loc: { + start: {line: 1, column: 30}, + end: {line: 1, column: 44} + } + }], + loc: { + start: {line: 1, column: 28}, + end: {line: 1, column: 46} + } + }, + generator: false, + expression: false, + async: true, + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 46} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('(function(x) { async function inner() { await x } })', { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "FunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "x", + loc: { + start: {line: 1, column: 10}, + end: {line: 1, column: 11} + } + } + ], + body: { + type: "BlockStatement", + body: [ + { + type: "FunctionDeclaration", + id: { + type: "Identifier", + name: "inner", + loc: { + start: {line: 1, column: 30}, + end: {line: 1, column: 35} + } + }, + params: [], + body: { + type: "BlockStatement", + body: [ + { + type: "ExpressionStatement", + expression: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "x", + loc: { + start: {line: 1, column: 46}, + end: {line: 1, column: 47} + } + }, + loc: { + start: {line: 1, column: 40}, + end: {line: 1, column: 47} + } + }, + loc: { + start: {line: 1, column: 40}, + end: {line: 1, column: 47} + } + } + ], + loc: { + start: {line: 1, column: 38}, + end: {line: 1, column: 49} + } + }, + generator: false, + expression: false, + async: true, + loc: { + start: {line: 1, column: 15}, + end: {line: 1, column: 49} + } + } + ], + loc: { + start: {line: 1, column: 13}, + end: {line: 1, column: 51} + } + }, + generator: false, + expression: false, + loc: { + start: {line: 1, column: 1}, + end: {line: 1, column: 51} + } + }, + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 52} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('var foo = async function(promise) { await promise; }', { + type: "Program", + body: [{ + type: "VariableDeclaration", + declarations: [ + { + type: "VariableDeclarator", + id: { + type: "Identifier", + name: "foo", + loc: { + start: {line: 1, column: 4}, + end: {line: 1, column: 7} + } + }, + init: { + type: "FunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 25}, + end: {line: 1, column: 32} + } + } + ], + body: { + type: "BlockStatement", + body: [ + { + type: "ExpressionStatement", + expression: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 42}, + end: {line: 1, column: 49} + } + }, + loc: { + start: {line: 1, column: 36}, + end: {line: 1, column: 49} + } + }, + loc: { + start: {line: 1, column: 36}, + end: {line: 1, column: 50} + } + } + ], + loc: { + start: {line: 1, column: 34}, + end: {line: 1, column: 52} + } + }, + generator: false, + expression: false, + async: true, + loc: { + start: {line: 1, column: 10}, + end: {line: 1, column: 52} + } + }, + loc: { + start: {line: 1, column: 4}, + end: {line: 1, column: 52} + } + } + ], + kind: "var", + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 52} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('var o = { a: 1, async foo(promise) { await promise } }', { + type: "Program", + body: [{ + type: "VariableDeclaration", + declarations: [ + { + type: "VariableDeclarator", + id: { + type: "Identifier", + name: "o", + loc: { + start: {line: 1, column: 4}, + end: {line: 1, column: 5} + } + }, + init: { + type: "ObjectExpression", + properties: [ + { + type: "Property", + key: { + type: "Identifier", + name: "a", + loc: { + start: {line: 1, column: 10}, + end: {line: 1, column: 11} + } + }, + value: { + type: "Literal", + value: 1, + loc: { + start: {line: 1, column: 13}, + end: {line: 1, column: 14} + } + }, + kind: "init", + method: false, + shorthand: false, + computed: false, + loc: { + start: {line: 1, column: 10}, + end: {line: 1, column: 14} + } + }, + { + type: "Property", + key: { + type: "Identifier", + name: "foo", + loc: { + start: {line: 1, column: 22}, + end: {line: 1, column: 25} + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 26}, + end: {line: 1, column: 33} + } + } + ], + body: { + type: "BlockStatement", + body: [ + { + type: "ExpressionStatement", + expression: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 43}, + end: {line: 1, column: 50} + } + }, + loc: { + start: {line: 1, column: 37}, + end: {line: 1, column: 50} + } + }, + loc: { + start: {line: 1, column: 37}, + end: {line: 1, column: 50} + } + } + ], + loc: { + start: {line: 1, column: 35}, + end: {line: 1, column: 52} + } + }, + generator: false, + expression: false, + async: true, + loc: { + start: {line: 1, column: 25}, + end: {line: 1, column: 52} + } + }, + kind: "init", + method: true, + shorthand: false, + computed: false, + loc: { + start: {line: 1, column: 16}, + end: {line: 1, column: 52} + } + } + ], + loc: { + start: {line: 1, column: 8}, + end: {line: 1, column: 54} + } + }, + loc: { + start: {line: 1, column: 4}, + end: {line: 1, column: 54} + } + } + ], + kind: "var", + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 54} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('class Foo { async bar(promise) { await promise } }', { + type: "Program", + body: [{ + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Foo", + loc: { + start: {line: 1, column: 6}, + end: {line: 1, column: 9} + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [ + { + type: "MethodDefinition", + key: { + type: "Identifier", + name: "bar", + loc: { + start: {line: 1, column: 18}, + end: {line: 1, column: 21} + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 22}, + end: {line: 1, column: 29} + } + } + ], + body: { + type: "BlockStatement", + body: [ + { + type: "ExpressionStatement", + expression: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 39}, + end: {line: 1, column: 46} + } + }, + loc: { + start: {line: 1, column: 33}, + end: {line: 1, column: 46} + } + }, + loc: { + start: {line: 1, column: 33}, + end: {line: 1, column: 46} + } + } + ], + loc: { + start: {line: 1, column: 31}, + end: {line: 1, column: 48} + } + }, + generator: false, + expression: false, + async: true, + loc: { + start: {line: 1, column: 21}, + end: {line: 1, column: 48} + } + }, + kind: "method", + static: false, + loc: { + start: {line: 1, column: 12}, + end: {line: 1, column: 48} + } + } + ], + loc: { + start: {line: 1, column: 10}, + end: {line: 1, column: 50} + } + }, + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 50} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('f(a, async promise => await promise)', { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "CallExpression", + callee: { + type: "Identifier", + name: "f", + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 1} + } + }, + arguments: [ + { + type: "Identifier", + name: "a", + loc: { + start: {line: 1, column: 2}, + end: {line: 1, column: 3} + } + }, + { + type: "ArrowFunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 11}, + end: {line: 1, column: 18} + } + } + ], + body: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 28}, + end: {line: 1, column: 35} + } + }, + loc: { + start: {line: 1, column: 22}, + end: {line: 1, column: 35} + } + }, + generator: false, + expression: true, + async: true, + loc: { + start: {line: 1, column: 5}, + end: {line: 1, column: 35} + } + } + ], + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 36} + } + }, + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 36} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('f(a, async(x, y) => await [x, y], b)', { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "CallExpression", + callee: { + type: "Identifier", + name: "f", + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 1} + } + }, + arguments: [ + { + type: "Identifier", + name: "a", + loc: { + start: {line: 1, column: 2}, + end: {line: 1, column: 3} + } + }, + { + type: "ArrowFunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "x", + loc: { + start: {line: 1, column: 11}, + end: {line: 1, column: 12} + } + }, + { + type: "Identifier", + name: "y", + loc: { + start: {line: 1, column: 14}, + end: {line: 1, column: 15} + } + } + ], + body: { + type: "AwaitExpression", + argument: { + type: "ArrayExpression", + elements: [ + { + type: "Identifier", + name: "x", + loc: { + start: {line: 1, column: 27}, + end: {line: 1, column: 28} + } + }, + { + type: "Identifier", + name: "y", + loc: { + start: {line: 1, column: 30}, + end: {line: 1, column: 31} + } + } + ], + loc: { + start: {line: 1, column: 26}, + end: {line: 1, column: 32} + } + }, + loc: { + start: {line: 1, column: 20}, + end: {line: 1, column: 32} + } + }, + generator: false, + expression: true, + async: true, + loc: { + start: {line: 1, column: 5}, + end: {line: 1, column: 32} + } + }, + { + type: "Identifier", + name: "b", + loc: { + start: {line: 1, column: 34}, + end: {line: 1, column: 35} + } + } + ], + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 36} + } + }, + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 36} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('f(async function(promise) { await promise })', { + type: "Program", + body: [{ + type: "ExpressionStatement", + expression: { + type: "CallExpression", + callee: { + type: "Identifier", + name: "f", + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 1} + } + }, + arguments: [ + { + type: "FunctionExpression", + id: null, + params: [ + { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 17}, + end: {line: 1, column: 24} + } + } + ], + body: { + type: "BlockStatement", + body: [ + { + type: "ExpressionStatement", + expression: { + type: "AwaitExpression", + argument: { + type: "Identifier", + name: "promise", + loc: { + start: {line: 1, column: 34}, + end: {line: 1, column: 41} + } + }, + loc: { + start: {line: 1, column: 28}, + end: {line: 1, column: 41} + } + }, + loc: { + start: {line: 1, column: 28}, + end: {line: 1, column: 41} + } + } + ], + loc: { + start: {line: 1, column: 26}, + end: {line: 1, column: 43} + } + }, + generator: false, + expression: false, + async: true, + loc: { + start: {line: 1, column: 2}, + end: {line: 1, column: 43} + } + } + ], + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 44} + } + }, + loc: { + start: {line: 1, column: 0}, + end: {line: 1, column: 44} + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true +}); + +test('f(a, async(1, 2), b)', { + type: "Program", + body: [{ + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "f", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "a", + "range": [ + 2, + 3 + ], + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "async", + "range": [ + 5, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 11, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "Literal", + "value": 2, + "raw": "2", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + ], + "range": [ + 5, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + { + "type": "Identifier", + "name": "b", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + } + } + ], + "range": [ + 0, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + "range": [ + 0, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true, + ranges: true +}); + +test('var ok = async(x)', { + type: "Program", + body: [{ + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "ok", + "range": [ + 4, + 6 + ], + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "async", + "range": [ + 9, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + ], + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + } + }, + "range": [ + 4, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 17 + } + } + } + ], + "kind": "var", + "range": [ + 0, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true, + ranges: true +}); + +test('(function() { var async; async = 10 })', { + type: "Program", + body: [{ + "type": "ExpressionStatement", + "expression": { + "type": "FunctionExpression", + "id": null, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "async", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + } + }, + "init": null, + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + } + } + ], + "kind": "var", + "range": [ + 14, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "async", + "range": [ + 25, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + "right": { + "type": "Literal", + "value": 10, + "raw": "10", + "range": [ + 33, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "range": [ + 25, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "range": [ + 25, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 35 + } + } + } + ], + "range": [ + 12, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 37 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 37 + } + } + }, + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true }, + locations: true, + ranges: true +}); + +test('class Test { async() {} }', { + type: "Program", + start: 0, + end: 25, + body: [{ + type: "ClassDeclaration", + start: 0, + end: 25, + id: { + type: "Identifier", + start: 6, + end: 10, + name: "Test" + }, + superClass: null, + body: { + type: "ClassBody", + start: 11, + end: 25, + body: [{ + type: "MethodDefinition", + start: 13, + end: 23, + static: false, + key: { + type: "Identifier", + start: 13, + end: 18, + name: "async" + }, + kind: "method", + value: { + type: "FunctionExpression", + start: 18, + end: 23, + id: null, + params: [], + generator: false, + async: false, + body: { + type: "BlockStatement", + start: 21, + end: 23, + body: [] + }, + expression: false + } + }] + } + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true } +}); + +test('var obj = { async: "test" };', { + type: "Program", + start: 0, + end: 28, + body: [{ + type: "VariableDeclaration", + start: 0, + end: 28, + declarations: [{ + type: "VariableDeclarator", + start: 4, + end: 27, + id: { + type: "Identifier", + start: 4, + end: 7, + name: "obj" + }, + init: { + type: "ObjectExpression", + start: 10, + end: 27, + properties: [{ + type: "Property", + start: 12, + end: 25, + method: false, + shorthand: false, + key: { + type: "Identifier", + start: 12, + end: 17, + name: "async" + }, + value: { + type: "Literal", + start: 19, + end: 25, + value: "test", + raw: "\"test\"" + }, + kind: "init" + }] + } + }], + kind: "var" + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true } +}); + +test('var obj = { async() {} };', { + type: "Program", + start: 0, + end: 25, + body: [{ + type: "VariableDeclaration", + start: 0, + end: 25, + declarations: [{ + type: "VariableDeclarator", + start: 4, + end: 24, + id: { + type: "Identifier", + start: 4, + end: 7, + name: "obj" + }, + init: { + type: "ObjectExpression", + start: 10, + end: 24, + properties: [{ + type: "Property", + start: 12, + end: 22, + method: true, + shorthand: false, + key: { + type: "Identifier", + start: 12, + end: 17, + name: "async" + }, + kind: "init", + value: { + type: "FunctionExpression", + start: 17, + end: 22, + id: null, + params: [], + generator: false, + body: { + type: "BlockStatement", + start: 20, + end: 22, + body: [] + }, + expression: false + } + }] + } + }], + kind: "var" + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true } +}); + +test('export async function foo(){}', { + "type": "Program", + "start": 0, + "end": 29, + "body": [{ + "type": "ExportNamedDeclaration", + "start": 0, + "end": 29, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 29, + "id": { + "type": "Identifier", + "start": 22, + "end": 25, + "name": "foo" + }, + "params": [], + "generator": false, + "async": true, + "body": { + "type": "BlockStatement", + "start": 27, + "end": 29, + "body": [] + }, + "expression": false + }, + "specifiers": [], + "source": null + }] +}, { + ecmaVersion: 7, + features: { "es7.asyncFunctions": true } +}); diff --git a/vendor/acorn/test/tests-flow.js b/vendor/acorn/test/tests-flow.js new file mode 100644 index 0000000000..ceac650d0a --- /dev/null +++ b/vendor/acorn/test/tests-flow.js @@ -0,0 +1,11125 @@ +// React JSX tests + +var fbTestFixture = { + 'Type Annotations': { + 'function foo(numVal: any){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'AnyTypeAnnotation', + range: [21, 24], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 24 } + } + }, + range: [19, 24], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 24 } + } + }, + range: [13, 24], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 24 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [25, 27], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 27 } + } + }, + generator: false, + expression: false, + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + 'function foo(numVal: number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }, + range: [19, 27], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 27 } + } + }, + range: [13, 27], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 27 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [28, 30], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 30 } + } + }, + generator: false, + expression: false, + range: [0, 30], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 30 } + } + }, + 'function foo(numVal: number, strVal: string){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }, + range: [19, 27], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 27 } + } + }, + range: [13, 27], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 27 } + } + }, { + type: 'Identifier', + name: 'strVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [37, 43], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 43 } + } + }, + range: [35, 43], + loc: { + start: { line: 1, column: 35 }, + end: { line: 1, column: 43 } + } + }, + range: [29, 43], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 43 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [44, 46], + loc: { + start: { line: 1, column: 44 }, + end: { line: 1, column: 46 } + } + }, + generator: false, + expression: false, + range: [0, 46], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 46 } + } + }, + 'function foo(numVal: number, untypedVal){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }, + range: [19, 27], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 27 } + } + }, + range: [13, 27], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 27 } + } + }, { + type: 'Identifier', + name: 'untypedVal', + range: [29, 39], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 39 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [40, 42], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 42 } + } + }, + generator: false, + expression: false, + range: [0, 42], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 42 } + } + }, + 'function foo(untypedVal, numVal: number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'untypedVal', + range: [13, 23], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 23 } + } + }, { + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [33, 39], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 39 } + } + }, + range: [31, 39], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 39 } + } + }, + range: [25, 39], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 39 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [40, 42], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 42 } + } + }, + generator: false, + expression: false, + range: [0, 42], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 42 } + } + }, + 'function foo(nullableNum: ?number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'nullableNum', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [27, 33], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 33 } + } + }, + range: [26, 33], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 33 } + } + }, + range: [24, 33], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 33 } + } + }, + range: [13, 33], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 33 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [34, 36], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 36 } + } + }, + generator: false, + expression: false, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'function foo(callback: () => void){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'callback', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'VoidTypeAnnotation', + range: [29, 33], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 33 } + } + }, + typeParameters: null, + range: [23, 33], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 33 } + } + }, + range: [21, 33], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 33 } + } + }, + range: [13, 33], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 33 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [34, 36], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 36 } + } + }, + generator: false, + expression: false, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'function foo(callback: () => number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'callback', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [29, 35], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 35 } + } + }, + typeParameters: null, + range: [23, 35], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 35 } + } + }, + range: [21, 35], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 35 } + } + }, + range: [13, 35], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 35 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [36, 38], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 38 } + } + }, + generator: false, + expression: false, + range: [0, 38], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 38 } + } + }, + 'function foo(callback: (_:bool) => number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'callback', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: '_', + range: [24, 25], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 25 } + } + }, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + range: [26, 30], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 30 } + } + }, + optional: false, + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [35, 41], + loc: { + start: { line: 1, column: 35 }, + end: { line: 1, column: 41 } + } + }, + typeParameters: null, + range: [23, 41], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 41 } + } + }, + range: [21, 41], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 41 } + } + }, + range: [13, 41], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 41 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [42, 44], + loc: { + start: { line: 1, column: 42 }, + end: { line: 1, column: 44 } + } + }, + generator: false, + expression: false, + range: [0, 44], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 44 } + } + }, + 'function foo(callback: (_1:bool, _2:string) => number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'callback', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: '_1', + range: [24, 26], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 26 } + } + }, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + range: [27, 31], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 31 } + } + }, + optional: false, + range: [24, 31], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 31 } + } + }, { + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: '_2', + range: [33, 35], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 35 } + } + }, + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [36, 42], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 42 } + } + }, + optional: false, + range: [33, 42], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 42 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [47, 53], + loc: { + start: { line: 1, column: 47 }, + end: { line: 1, column: 53 } + } + }, + typeParameters: null, + range: [23, 53], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 53 } + } + }, + range: [21, 53], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 53 } + } + }, + range: [13, 53], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 53 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [54, 56], + loc: { + start: { line: 1, column: 54 }, + end: { line: 1, column: 56 } + } + }, + generator: false, + expression: false, + range: [0, 56], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 56 } + } + }, + 'function foo(callback: (_1:bool, ...foo:Array) => number){}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'callback', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: '_1', + range: [24, 26], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 26 } + } + }, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + range: [27, 31], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 31 } + } + }, + optional: false, + range: [24, 31], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 31 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [58, 64], + loc: { + start: { line: 1, column: 58 }, + end: { line: 1, column: 64 } + } + }, + rest: { + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'foo', + range: [36, 39], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 39 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [40, 45], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 45 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'NumberTypeAnnotation', + range: [46, 52], + loc: { + start: { line: 1, column: 46 }, + end: { line: 1, column: 52 } + } + }], + range: [45, 53], + loc: { + start: { line: 1, column: 45 }, + end: { line: 1, column: 53 } + } + }, + range: [40, 53], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 53 } + } + }, + optional: false, + range: [36, 53], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 53 } + } + }, + typeParameters: null, + range: [23, 64], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 64 } + } + }, + range: [21, 64], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 64 } + } + }, + range: [13, 64], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 64 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [65, 67], + loc: { + start: { line: 1, column: 65 }, + end: { line: 1, column: 67 } + } + }, + generator: false, + expression: false, + range: [0, 67], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 67 } + } + }, + 'function foo():number{}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [21, 23], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 23 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [15, 21], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 21 } + } + }, + range: [14, 21], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 21 } + } + }, + range: [0, 23], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 23 } + } + }, + 'function foo():() => void{}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [25, 27], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 27 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'VoidTypeAnnotation', + range: [21, 25], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 25 } + } + }, + typeParameters: null, + range: [15, 25], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 25 } + } + }, + range: [14, 25], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 25 } + } + }, + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + 'function foo():(_:bool) => number{}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [33, 35], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 35 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: '_', + range: [16, 17], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + } + }, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + range: [18, 22], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [27, 33], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 33 } + } + }, + typeParameters: null, + range: [15, 33], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 33 } + } + }, + range: [14, 33], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 33 } + } + }, + range: [0, 35], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 35 } + } + }, + 'function foo():(_?:bool) => number{}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [34, 36], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 36 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: '_', + range: [16, 17], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + } + }, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + range: [19, 23], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 23 } + } + }, + optional: true, + range: [16, 23], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 23 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [28, 34], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 34 } + } + }, + typeParameters: null, + range: [15, 34], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 34 } + } + }, + range: [14, 34], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 34 } + } + }, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'function foo(): {} {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [19, 21], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 21 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [], + range: [16, 18], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 18 } + } + }, + range: [14, 18], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 18 } + } + }, + range: [0, 21], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 21 } + } + }, + 'function foo() {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [18, 20], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 20 } + } + }, + generator: false, + expression: false, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }], + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }, + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + 'function foo() {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [20, 22], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 22 } + } + }, + generator: false, + expression: false, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, { + type: 'Identifier', + name: 'S', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }], + range: [12, 17], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 17 } + } + }, + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + 'a=function() {}': { + type: 'ExpressionStatement', + expression: { + type: 'AssignmentExpression', + operator: '=', + left: { + type: 'Identifier', + name: 'a', + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: 'FunctionExpression', + id: null, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [18, 20], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 20 } + } + }, + generator: false, + expression: false, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [11, 12], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 12 } + } + }, { + type: 'Identifier', + name: 'S', + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }], + range: [10, 15], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 15 } + } + }, + range: [2, 20], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 20 } + } + }, + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + "a={set fooProp(value:number){}}": { + type: "ExpressionStatement", + expression: { + type: "AssignmentExpression", + operator: "=", + left: { + type: "Identifier", + name: "a", + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: "ObjectExpression", + properties: [{ + type: "Property", + key: { + type: "Identifier", + name: "fooProp", + range: [7, 14], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "value", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }, + range: [20, 27], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 27 } + } + }, + range: [15, 27], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 27 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [28, 30], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 30 } + } + }, + generator: false, + expression: false, + //range: [28, 30], + //loc: { + // start: { line: 1, column: 28 }, + // end: { line: 1, column: 30 } + //} + }, + kind: "set", + method: false, + shorthand: false, + computed: false, + range: [3, 30], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 30 } + } + }], + range: [2, 31], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 31 } + } + }, + range: [0, 31], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 31 } + } + }, + range: [0, 31], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 31 } + } + }, + "a={set fooProp(value:number):void{}}": { + type: "ExpressionStatement", + expression: { + type: "AssignmentExpression", + operator: "=", + left: { + type: "Identifier", + name: "a", + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: "ObjectExpression", + properties: [{ + type: "Property", + key: { + type: "Identifier", + name: "fooProp", + range: [7, 14], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "value", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }, + range: [20, 27], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 27 } + } + }, + range: [15, 27], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 27 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [33, 35], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 35 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "VoidTypeAnnotation", + range: [29, 33], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 33 } + } + }, + range: [28, 33], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 33 } + } + }, + //range: [33, 35], + //loc: { + // start: { line: 1, column: 33 }, + // end: { line: 1, column: 35 } + //} + }, + kind: "set", + method: false, + shorthand: false, + computed: false, + range: [3, 35], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 35 } + } + }], + range: [2, 36], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 36 } + } + }, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + "a={get fooProp():number{}}": { + type: "ExpressionStatement", + expression: { + type: "AssignmentExpression", + operator: "=", + left: { + type: "Identifier", + name: "a", + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: "ObjectExpression", + properties: [{ + type: "Property", + key: { + type: "Identifier", + name: "fooProp", + range: [7, 14], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [], + body: { + type: "BlockStatement", + body: [], + range: [23, 25], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 25 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }, + range: [16, 23], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 23 } + } + }, + //range: [23, 25], + //loc: { + // start: { line: 1, column: 23 }, + // end: { line: 1, column: 25 } + //} + }, + kind: "get", + method: false, + shorthand: false, + computed: false, + range: [3, 25], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 25 } + } + }], + range: [2, 26], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 26 } + } + }, + range: [0, 26], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 26 } + } + }, + range: [0, 26], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 26 } + } + }, + 'a={id(x: T): T {}}': { + type: "ExpressionStatement", + expression: { + type: "AssignmentExpression", + operator: "=", + left: { + type: "Identifier", + name: "a", + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: "ObjectExpression", + properties: [{ + type: "Property", + key: { + type: "Identifier", + name: "id", + range: [3, 5], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 5 } + } + }, + value: { + type: "FunctionExpression", + //id: null, + params: [{ + type: "Identifier", + name: "x", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "GenericTypeAnnotation", + id: { + type: "Identifier", + name: "T", + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }, + typeParameters: null, + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }, + range: [10, 13], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 13 } + } + }, + range: [9, 13], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 13 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [18, 20], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 20 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "GenericTypeAnnotation", + id: { + type: "Identifier", + name: "T", + range: [16, 17], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + } + }, + typeParameters: null, + range: [16, 17], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + } + }, + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + typeParameters: { + type: "TypeParameterDeclaration", + params: [{ + type: "Identifier", + name: "T", + range: [6, 7], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 7 } + } + }], + range: [5, 8], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 8 } + } + }, + //range: [18, 20], + //loc: { + // start: { line: 1, column: 18 }, + // end: { line: 1, column: 20 } + //} + }, + kind: "init", + method: true, + shorthand: false, + computed: false, + range: [3, 20], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 20 } + } + }], + range: [2, 21], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 21 } + } + }, + range: [0, 21], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 21 } + } + }, + range: [0, 21], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 21 } + } + }, + 'a={*id(x: T): T {}}': { + type: "ExpressionStatement", + expression: { + type: "AssignmentExpression", + operator: "=", + left: { + type: "Identifier", + name: "a", + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: "ObjectExpression", + properties: [{ + type: "Property", + key: { + type: "Identifier", + name: "id", + range: [4, 6], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 6 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "x", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "GenericTypeAnnotation", + id: { + type: "Identifier", + name: "T", + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, + typeParameters: null, + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + range: [10, 14], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 14 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [19, 21], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 21 } + } + }, + generator: true, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "GenericTypeAnnotation", + id: { + type: "Identifier", + name: "T", + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: null, + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + range: [15, 18], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: { + type: "TypeParameterDeclaration", + params: [{ + type: "Identifier", + name: "T", + range: [7, 8], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + } + }], + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + //range: [19, 21], + //loc: { + // start: { line: 1, column: 19 }, + // end: { line: 1, column: 21 } + //} + }, + kind: "init", + method: true, + shorthand: false, + computed: false, + //range: [3, 21], + //loc: { + // start: { line: 1, column: 3 }, + // end: { line: 1, column: 21 } + //} + }], + range: [2, 22], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 22 } + } + }, + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + 'a={async id(x: T): T {}}': { + type: 'ExpressionStatement', + expression: { + type: 'AssignmentExpression', + operator: '=', + left: { + type: 'Identifier', + name: 'a', + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: 'ObjectExpression', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'id', + range: [9, 11], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 11 } + } + }, + value: { + type: 'FunctionExpression', + id: null, + params: [{ + type: 'Identifier', + name: 'x', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + typeParameters: null, + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + range: [16, 19], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 19 } + } + }, + range: [15, 19], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [24, 26], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 26 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [22, 23], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + } + }, + typeParameters: null, + range: [22, 23], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + } + }, + range: [20, 23], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }], + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + async: true, + //range: [24, 26], + //loc: { + // start: { line: 1, column: 24 }, + // end: { line: 1, column: 26 } + //} + }, + kind: 'init', + method: true, + shorthand: false, + computed: false, + range: [3, 26], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 26 } + } + }], + range: [2, 27], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 27 } + } + }, + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + 'a={123(x: T): T {}}': { + type: "ExpressionStatement", + expression: { + type: "AssignmentExpression", + operator: "=", + left: { + type: "Identifier", + name: "a", + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: "ObjectExpression", + properties: [{ + type: "Property", + key: { + type: "Literal", + value: 123, + raw: "123", + range: [3, 6], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 6 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "x", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "GenericTypeAnnotation", + id: { + type: "Identifier", + name: "T", + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, + typeParameters: null, + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + range: [10, 14], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 14 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [19, 21], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 21 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "GenericTypeAnnotation", + id: { + type: "Identifier", + name: "T", + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: null, + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + range: [15, 18], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: { + type: "TypeParameterDeclaration", + params: [{ + type: "Identifier", + name: "T", + range: [7, 8], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + } + }], + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + //range: [19, 21], + //loc: { + // start: { line: 1, column: 19 }, + // end: { line: 1, column: 21 } + //} + }, + kind: "init", + method: true, + shorthand: false, + computed: false, + range: [3, 21], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 21 } + } + }], + range: [2, 22], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 22 } + } + }, + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + "class Foo {set fooProp(value:number){}}": { + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Foo", + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + key: { + type: "Identifier", + name: "fooProp", + range: [15, 22], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 22 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "value", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [29, 35], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 35 } + } + }, + range: [28, 35], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 35 } + } + }, + range: [23, 35], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 35 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [36, 38], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 38 } + } + }, + generator: false, + expression: false, + //range: [36, 38], + //loc: { + // start: { line: 1, column: 36 }, + // end: { line: 1, column: 38 } + //} + }, + kind: "set", + "static": false, + computed: false, + range: [11, 38], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 38 } + } + }], + range: [10, 39], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 39 } + } + }, + range: [0, 39], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 39 } + } + }, + 'class Foo {set fooProp(value:number):void{}}': { + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Foo", + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + key: { + type: "Identifier", + name: "fooProp", + range: [15, 22], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 22 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "value", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [29, 35], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 35 } + } + }, + range: [28, 35], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 35 } + } + }, + range: [23, 35], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 35 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [41, 43], + loc: { + start: { line: 1, column: 41 }, + end: { line: 1, column: 43 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "VoidTypeAnnotation", + range: [37, 41], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 41 } + } + }, + range: [36, 41], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 41 } + } + }, + //range: [41, 43], + //loc: { + // start: { line: 1, column: 41 }, + // end: { line: 1, column: 43 } + //} + }, + kind: "set", + "static": false, + computed: false, + range: [11, 43], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 43 } + } + }], + range: [10, 44], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 44 } + } + }, + range: [0, 44], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 44 } + } + }, + 'class Foo {get fooProp():number{}}': { + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Foo", + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + key: { + type: "Identifier", + name: "fooProp", + range: [15, 22], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 22 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [], + body: { + type: "BlockStatement", + body: [], + range: [31, 33], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 33 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }, + range: [24, 31], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 31 } + } + }, + //range: [31, 33], + //loc: { + // start: { line: 1, column: 31 }, + // end: { line: 1, column: 33 } + //} + }, + kind: "get", + "static": false, + computed: false, + range: [11, 33], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 33 } + } + }], + range: [10, 34], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 34 } + } + }, + range: [0, 34], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 34 } + } + }, + 'var numVal:number;': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [11, 17], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 17 } + } + }, + range: [10, 17], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 17 } + } + }, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }, + init: null, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }], + kind: 'var', + range: [0, 18], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 18 } + } + }, + 'var numVal:number = otherNumVal;': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'numVal', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [11, 17], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 17 } + } + }, + range: [10, 17], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 17 } + } + }, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }, + init: { + type: 'Identifier', + name: 'otherNumVal', + range: [20, 31], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 31 } + } + }, + range: [4, 31], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 31 } + } + }], + kind: 'var', + range: [0, 32], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 32 } + } + }, + 'var a: {numVal: number};': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'numVal', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }], + indexers: [], + callProperties: [], + range: [7, 23], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 23 } + } + }, + range: [5, 23], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 23 } + } + }, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }, + init: null, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }], + kind: 'var', + range: [0, 24], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 24 } + } + }, + 'var a: {numVal: number;};': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'numVal', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }], + indexers: [], + callProperties: [], + range: [7, 24], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 24 } + } + }, + range: [5, 24], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 24 } + } + }, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }, + init: null, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }], + kind: 'var', + range: [0, 25], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 25 } + } + }, + 'var a: {numVal: number; [indexer: string]: number};': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'numVal', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }], + indexers: [{ + type: 'ObjectTypeIndexer', + id: { + type: 'Identifier', + name: 'indexer', + range: [25, 32], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 32 } + } + }, + key: { + type: 'StringTypeAnnotation', + range: [34, 40], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 40 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [43, 49], + loc: { + start: { line: 1, column: 43 }, + end: { line: 1, column: 49 } + } + }, + range: [24, 49], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 49 } + } + }], + callProperties: [], + range: [7, 50], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 50 } + } + }, + range: [5, 50], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 50 } + } + }, + range: [4, 50], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 50 } + } + }, + init: null, + range: [4, 50], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 50 } + } + }], + kind: 'var', + range: [0, 51], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 51 } + } + }, + 'var a: ?{numVal: number};': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'numVal', + range: [9, 15], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 15 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }, + optional: false, + range: [9, 23], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 23 } + } + }], + indexers: [], + callProperties: [], + range: [8, 24], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 24 } + } + }, + range: [7, 24], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 24 } + } + }, + range: [5, 24], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 24 } + } + }, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }, + init: null, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }], + kind: 'var', + range: [0, 25], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 25 } + } + }, + 'var a: {numVal: number; strVal: string}': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'numVal', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }, { + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'strVal', + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [32, 38], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 38 } + } + }, + optional: false, + range: [24, 38], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 38 } + } + }], + indexers: [], + callProperties: [], + range: [7, 39], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 39 } + } + }, + range: [5, 39], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 39 } + } + }, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }, + init: null, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }], + kind: 'var', + range: [0, 39], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 39 } + } + }, + 'var a: {subObj: {strVal: string}}': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'subObj', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'strVal', + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }, + optional: false, + range: [17, 31], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 31 } + } + }], + indexers: [], + callProperties: [], + range: [16, 32], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 32 } + } + }, + optional: false, + range: [8, 32], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 32 } + } + }], + indexers: [], + callProperties: [], + range: [7, 33], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 33 } + } + }, + range: [5, 33], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 33 } + } + }, + range: [4, 33], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 33 } + } + }, + init: null, + range: [4, 33], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 33 } + } + }], + kind: 'var', + range: [0, 33], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 33 } + } + }, + 'var a: {subObj: ?{strVal: string}}': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'subObj', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'strVal', + range: [18, 24], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 24 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [26, 32], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 32 } + } + }, + optional: false, + range: [18, 32], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 32 } + } + }], + indexers: [], + callProperties: [], + range: [17, 33], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 33 } + } + }, + range: [16, 33], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 33 } + } + }, + optional: false, + range: [8, 33], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 33 } + } + }], + indexers: [], + callProperties: [], + range: [7, 34], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 34 } + } + }, + range: [5, 34], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 34 } + } + }, + range: [4, 34], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 34 } + } + }, + init: null, + range: [4, 34], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 34 } + } + }], + kind: 'var', + range: [0, 34], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 34 } + } + }, + 'var a: {param1: number; param2: string}': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'param1', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }, { + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'param2', + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [32, 38], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 38 } + } + }, + optional: false, + range: [24, 38], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 38 } + } + }], + indexers: [], + callProperties: [], + range: [7, 39], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 39 } + } + }, + range: [5, 39], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 39 } + } + }, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }, + init: null, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }], + kind: 'var', + range: [0, 39], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 39 } + } + }, + 'var a: {param1: number; param2?: string}': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'param1', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [16, 22], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }, { + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'param2', + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [33, 39], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 39 } + } + }, + optional: true, + range: [24, 39], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 39 } + } + }], + indexers: [], + callProperties: [], + range: [7, 40], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 40 } + } + }, + range: [5, 40], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 40 } + } + }, + range: [4, 40], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 40 } + } + }, + init: null, + range: [4, 40], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 40 } + } + }], + kind: 'var', + range: [0, 40], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 40 } + } + }, + 'var a: { [a: number]: string; [b: number]: string; };': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [{ + type: 'ObjectTypeIndexer', + id: { + type: 'Identifier', + name: 'a', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + key: { + type: 'NumberTypeAnnotation', + range: [13, 19], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 19 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [22, 28], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 28 } + } + }, + range: [9, 28], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 28 } + } + }, { + type: 'ObjectTypeIndexer', + id: { + type: 'Identifier', + name: 'b', + range: [31, 32], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 32 } + } + }, + key: { + type: 'NumberTypeAnnotation', + range: [34, 40], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 40 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [43, 49], + loc: { + start: { line: 1, column: 43 }, + end: { line: 1, column: 49 } + } + }, + range: [30, 49], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 49 } + } + }], + callProperties: [], + range: [7, 52], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 52 } + } + }, + range: [5, 52], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 52 } + } + }, + range: [4, 52], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 52 } + } + }, + init: null, + range: [4, 52], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 52 } + } + }], + kind: 'var', + range: [0, 53], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 53 } + } + }, + 'var a: {add(x:number, ...y:Array): void}': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'add', + range: [8, 11], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 11 } + } + }, + value: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }, + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + optional: false, + range: [12, 20], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 20 } + } + }], + returnType: { + type: 'VoidTypeAnnotation', + range: [43, 47], + loc: { + start: { line: 1, column: 43 }, + end: { line: 1, column: 47 } + } + }, + rest: { + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'y', + range: [25, 26], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [27, 32], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 32 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [33, 39], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 39 } + } + }], + range: [32, 40], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 40 } + } + }, + range: [27, 40], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 40 } + } + }, + optional: false, + range: [25, 40], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 40 } + } + }, + typeParameters: null, + range: [8, 47], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 47 } + } + }, + optional: false, + range: [8, 47], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 47 } + } + }], + indexers: [], + callProperties: [], + range: [7, 48], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 48 } + } + }, + range: [5, 48], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 48 } + } + }, + range: [4, 48], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 48 } + } + }, + init: null, + range: [4, 48], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 48 } + } + }], + kind: 'var', + range: [0, 48], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 48 } + } + }, + 'var a: { id(x: T): T; }': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'id', + range: [9, 11], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 11 } + } + }, + value: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + typeParameters: null, + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + optional: false, + range: [15, 19], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + } + }], + returnType: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [22, 23], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + } + }, + typeParameters: null, + range: [22, 23], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }], + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + range: [9, 23], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 23 } + } + }, + optional: false, + range: [9, 23], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 23 } + } + }], + indexers: [], + callProperties: [], + range: [7, 26], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 26 } + } + }, + range: [5, 26], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 26 } + } + }, + range: [4, 26], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 26 } + } + }, + init: null, + range: [4, 26], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 26 } + } + }], + kind: 'var', + range: [0, 26], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 26 } + } + }, + 'var a:Array = [1, 2, 3]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [6, 11], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'NumberTypeAnnotation', + range: [12, 18], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 18 } + } + }], + range: [11, 19], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 19 } + } + }, + range: [6, 19], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 19 } + } + }, + range: [5, 19], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 19 } + } + }, + range: [4, 19], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 19 } + } + }, + init: { + type: 'ArrayExpression', + elements: [{ + type: 'Literal', + value: 1, + raw: '1', + range: [23, 24], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 24 } + } + }, { + type: 'Literal', + value: 2, + raw: '2', + range: [26, 27], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 27 } + } + }, { + type: 'Literal', + value: 3, + raw: '3', + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }], + range: [22, 31], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 31 } + } + }, + range: [4, 31], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 31 } + } + }], + kind: 'var', + range: [0, 31], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 31 } + } + }, + 'a = class Foo { }': { + type: 'ExpressionStatement', + expression: { + type: 'AssignmentExpression', + operator: '=', + left: { + type: 'Identifier', + name: 'a', + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: 'ClassExpression', + id: { + type: 'Identifier', + name: 'Foo', + range: [10, 13], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 13 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [], + range: [17, 20], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }], + range: [13, 16], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 16 } + } + }, + range: [4, 20], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 20 } + } + }, + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + 'a = class Foo extends Bar { }': { + type: 'ExpressionStatement', + expression: { + type: 'AssignmentExpression', + operator: '=', + left: { + type: 'Identifier', + name: 'a', + range: [0, 1], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + } + }, + right: { + type: 'ClassExpression', + id: { + type: 'Identifier', + name: 'Foo', + range: [10, 13], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 13 } + } + }, + superClass: { + type: 'Identifier', + name: 'Bar', + range: [25, 28], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 28 } + } + }, + body: { + type: 'ClassBody', + body: [], + range: [32, 35], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 35 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }], + range: [13, 16], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 16 } + } + }, + superTypeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }, + typeParameters: null, + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }], + range: [28, 31], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 31 } + } + }, + range: [4, 35], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 35 } + } + }, + range: [0, 35], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 35 } + } + }, + range: [0, 35], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 35 } + } + }, + 'class Foo {}': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [], + range: [13, 15], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }], + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + 'class Foo extends Bar { }': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: { + type: 'Identifier', + name: 'Bar', + range: [21, 24], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 24 } + } + }, + body: { + type: 'ClassBody', + body: [], + range: [28, 31], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 31 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }], + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + superTypeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [25, 26], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + } + }, + typeParameters: null, + range: [25, 26], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + } + }], + range: [24, 27], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 27 } + } + }, + range: [0, 31], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 31 } + } + }, + 'class Foo extends mixin(Bar) { }': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: { + type: 'CallExpression', + callee: { + type: 'Identifier', + name: 'mixin', + range: [21, 26], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 26 } + } + }, + 'arguments': [{ + type: 'Identifier', + name: 'Bar', + range: [27, 30], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 30 } + } + }], + range: [21, 31], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 31 } + } + }, + body: { + type: 'ClassBody', + body: [], + range: [32, 35], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 35 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }], + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + range: [0, 35], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 35 } + } + }, + 'class Foo { bar():number { return 42; }}': { + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Foo", + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + key: { + type: "Identifier", + name: "bar", + range: [15, 18], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [], + body: { + type: "BlockStatement", + body: [{ + type: "ReturnStatement", + argument: { + type: "Literal", + value: 42, + raw: "42", + range: [40, 42], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 42 } + } + }, + range: [33, 43], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 43 } + } + }], + range: [31, 45], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 45 } + } + }, + generator: false, + expression: false, + returnType: { + type: "TypeAnnotation", + typeAnnotation: { + type: "NumberTypeAnnotation", + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }, + range: [23, 30], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 30 } + } + }, + typeParameters: { + type: "TypeParameterDeclaration", + params: [{ + type: "Identifier", + name: "U", + range: [19, 20], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + } + }], + range: [18, 21], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 21 } + } + }, + //range: [31, 45], + //loc: { + // start: { line: 1, column: 31 }, + // end: { line: 1, column: 45 } + //} + }, + kind: "method", + "static": false, + computed: false, + range: [15, 45], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 45 } + } + }], + range: [13, 46], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 46 } + } + }, + typeParameters: { + type: "TypeParameterDeclaration", + params: [{ + type: "Identifier", + name: "T", + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }], + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + range: [0, 46], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 46 } + } + }, + 'class Foo { "bar"() { } }': { + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Foo", + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + key: { + type: "Literal", + value: "bar", + raw: '"bar"', + range: [12, 17], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 17 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [], + body: { + type: "BlockStatement", + body: [], + range: [23, 26], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 26 } + } + }, + generator: false, + expression: false, + typeParameters: { + type: "TypeParameterDeclaration", + params: [{ + type: "Identifier", + name: "T", + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }], + range: [17, 20], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 20 } + } + }, + //range: [23, 26], + //loc: { + // start: { line: 1, column: 23 }, + // end: { line: 1, column: 26 } + //} + }, + kind: "method", + "static": false, + computed: false, + range: [12, 26], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 26 } + } + }], + range: [10, 28], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 28 } + } + }, + range: [0, 28], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 28 } + } + }, + 'function foo(requiredParam, optParam?) {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'Identifier', + name: 'requiredParam', + range: [13, 26], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 26 } + } + }, { + type: 'Identifier', + name: 'optParam', + optional: true, + range: [28, 37], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 37 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [39, 41], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 41 } + } + }, + generator: false, + expression: false, + range: [0, 41], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 41 } + } + }, + 'class Foo { prop1:string; prop2:number; }': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [{ + type: 'ClassProperty', + key: { + type: 'Identifier', + name: 'prop1', + range: [12, 17], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 17 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [18, 24], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 24 } + } + }, + range: [17, 24], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 24 } + } + }, + computed: false, + 'static': false, + range: [12, 25], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 25 } + } + }, { + type: 'ClassProperty', + key: { + type: 'Identifier', + name: 'prop2', + range: [26, 31], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 31 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [32, 38], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 38 } + } + }, + range: [31, 38], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 38 } + } + }, + computed: false, + 'static': false, + range: [26, 39], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 39 } + } + }], + range: [10, 41], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 41 } + } + }, + range: [0, 41], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 41 } + } + }, + 'class Foo { static prop1:string; prop2:number; }': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [{ + type: 'ClassProperty', + key: { + type: 'Identifier', + name: 'prop1', + range: [19, 24], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 24 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }, + range: [24, 31], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 31 } + } + }, + computed: false, + 'static': true, + range: [12, 32], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 32 } + } + }, { + type: 'ClassProperty', + key: { + type: 'Identifier', + name: 'prop2', + range: [33, 38], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 38 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [39, 45], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 45 } + } + }, + range: [38, 45], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 45 } + } + }, + computed: false, + 'static': false, + range: [33, 46], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 46 } + } + }], + range: [10, 48], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 48 } + } + }, + range: [0, 48], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 48 } + } + }, + 'var x : number | string = 4;': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'x', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'UnionTypeAnnotation', + types: [{ + type: 'NumberTypeAnnotation', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, { + type: 'StringTypeAnnotation', + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }], + range: [8, 23], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 23 } + } + }, + range: [6, 23], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 23 } + } + }, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }, + init: { + type: 'Literal', + value: 4, + raw: '4', + range: [26, 27], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 27 } + } + }, + range: [4, 27], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 27 } + } + }], + kind: 'var', + range: [0, 28], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 28 } + } + }, + "class Array { concat(items:number | string) {}; }": { + type: "ClassDeclaration", + id: { + type: "Identifier", + name: "Array", + range: [6, 11], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 11 } + } + }, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + key: { + type: "Identifier", + name: "concat", + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + value: { + type: "FunctionExpression", + id: null, + params: [{ + type: "Identifier", + name: "items", + typeAnnotation: { + type: "TypeAnnotation", + typeAnnotation: { + type: "UnionTypeAnnotation", + types: [{ + type: "NumberTypeAnnotation", + range: [27, 33], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 33 } + } + }, { + type: "StringTypeAnnotation", + range: [36, 42], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 42 } + } + }], + range: [27, 42], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 42 } + } + }, + range: [26, 42], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 42 } + } + }, + range: [21, 42], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 42 } + } + }], + body: { + type: "BlockStatement", + body: [], + range: [44, 46], + loc: { + start: { line: 1, column: 44 }, + end: { line: 1, column: 46 } + } + }, + generator: false, + expression: false, + //range: [44, 46], + //loc: { + // start: { line: 1, column: 44 }, + // end: { line: 1, column: 46 } + //} + }, + kind: "method", + "static": false, + computed: false, + range: [14, 46], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 46 } + } + }], + range: [12, 49], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 49 } + } + }, + range: [0, 49], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 49 } + } + }, + 'var x : () => number | () => string = fn;': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'x', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'UnionTypeAnnotation', + types: [{ + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'StringTypeAnnotation', + range: [29, 35], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 35 } + } + }, + typeParameters: null, + range: [23, 35], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 35 } + } + }], + range: [14, 35], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 35 } + } + }, + typeParameters: null, + range: [8, 35], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 35 } + } + }, + range: [6, 35], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 35 } + } + }, + range: [4, 35], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 35 } + } + }, + init: { + type: 'Identifier', + name: 'fn', + range: [38, 40], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 40 } + } + }, + range: [4, 40], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 40 } + } + }], + kind: 'var', + range: [0, 41], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 41 } + } + }, + 'var x: typeof Y = Y;': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'x', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TypeofTypeAnnotation', + argument: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Y', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, + range: [5, 15], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 15 } + } + }, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }, + init: { + type: 'Identifier', + name: 'Y', + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + range: [4, 19], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 19 } + } + }], + kind: 'var', + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + 'var x: typeof Y | number = Y;': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'x', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'UnionTypeAnnotation', + types: [{ + type: 'TypeofTypeAnnotation', + argument: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Y', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, { + type: 'NumberTypeAnnotation', + range: [18, 24], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 24 } + } + }], + range: [7, 24], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 24 } + } + }, + range: [5, 24], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 24 } + } + }, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }, + init: { + type: 'Identifier', + name: 'Y', + range: [27, 28], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + } + }, + range: [4, 28], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 28 } + } + }], + kind: 'var', + range: [0, 29], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 29 } + } + }, + 'var {x}: {x: string; } = { x: "hello" };': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'ObjectPattern', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'x', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }, + value: { + type: 'Identifier', + name: 'x', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }, + kind: 'init', + method: false, + shorthand: true, + computed: false, + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }], + range: [4, 22], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 22 } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'x', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [13, 19], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 19 } + } + }, + optional: false, + range: [10, 19], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 19 } + } + }], + indexers: [], + callProperties: [], + range: [9, 22], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 22 } + } + }, + range: [7, 22], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 22 } + } + } + }, + init: { + type: 'ObjectExpression', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'x', + range: [27, 28], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + } + }, + value: { + type: 'Literal', + value: 'hello', + raw: '"hello"', + range: [30, 37], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 37 } + } + }, + kind: 'init', + method: false, + shorthand: false, + computed: false, + range: [27, 37], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 37 } + } + }], + range: [25, 39], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 39 } + } + }, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }], + kind: 'var', + range: [0, 40], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 40 } + } + }, + 'var {x}: {x: string } = { x: "hello" };': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'ObjectPattern', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'x', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }, + value: { + type: 'Identifier', + name: 'x', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }, + kind: 'init', + method: false, + shorthand: true, + computed: false, + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }], + range: [4, 21], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 21 } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'x', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [13, 19], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 19 } + } + }, + optional: false, + range: [10, 19], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 19 } + } + }], + indexers: [], + callProperties: [], + range: [9, 21], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 21 } + } + }, + range: [7, 21], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 21 } + } + } + }, + init: { + type: 'ObjectExpression', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'x', + range: [26, 27], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 27 } + } + }, + value: { + type: 'Literal', + value: 'hello', + raw: '"hello"', + range: [29, 36], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 36 } + } + }, + kind: 'init', + method: false, + shorthand: false, + computed: false, + range: [26, 36], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 36 } + } + }], + range: [24, 38], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 38 } + } + }, + range: [4, 38], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 38 } + } + }], + kind: 'var', + range: [0, 39], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 39 } + } + }, + 'var [x]: Array = [ "hello" ];': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'ArrayPattern', + elements: [{ + type: 'Identifier', + name: 'x', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }], + range: [4, 22], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 22 } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [9, 14], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 14 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [15, 21], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 21 } + } + }], + range: [14, 22], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 22 } + } + }, + range: [9, 22], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 22 } + } + }, + range: [7, 22], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 22 } + } + } + }, + init: { + type: 'ArrayExpression', + elements: [{ + type: 'Literal', + value: 'hello', + raw: '"hello"', + range: [27, 34], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 34 } + } + }], + range: [25, 36], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 36 } + } + }, + range: [4, 36], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 36 } + } + }], + kind: 'var', + range: [0, 37], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 37 } + } + }, + 'function foo({x}: { x: string; }) {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'ObjectPattern', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'x', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + value: { + type: 'Identifier', + name: 'x', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + kind: 'init', + method: false, + shorthand: true, + computed: false, + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }], + range: [13, 32], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 32 } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'x', + range: [20, 21], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 21 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [23, 29], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 29 } + } + }, + optional: false, + range: [20, 29], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 29 } + } + }], + indexers: [], + callProperties: [], + range: [18, 32], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 32 } + } + }, + range: [16, 32], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 32 } + } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [34, 36], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 36 } + } + }, + generator: false, + expression: false, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'function foo([x]: Array) {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [{ + type: 'ArrayPattern', + elements: [{ + type: 'Identifier', + name: 'x', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }], + range: [13, 31], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 31 } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [18, 23], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 23 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }], + range: [23, 31], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 31 } + } + }, + range: [18, 31], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 31 } + } + }, + range: [16, 31], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 31 } + } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [33, 35], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 35 } + } + }, + generator: false, + expression: false, + range: [0, 35], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 35 } + } + }, + "function foo(...rest: Array) {}": { + type: "FunctionDeclaration", + start: 0, + end: 39, + id: { + type: "Identifier", + start: 9, + end: 12, + name: "foo" + }, + generator: false, + expression: false, + params: [{ + type: "RestElement", + start: 13, + end: 35, + argument: { + type: "Identifier", + start: 16, + end: 20, + name: "rest" + }, + typeAnnotation: { + type: "TypeAnnotation", + start: 20, + end: 35, + typeAnnotation: { + type: "GenericTypeAnnotation", + start: 22, + end: 35, + typeParameters: { + type: "TypeParameterInstantiation", + start: 27, + end: 35, + params: [ + { + type: "NumberTypeAnnotation", + start: 28, + end: 34 + } + ] + }, + id: { + type: "Identifier", + start: 22, + end: 27, + name: "Array" + } + } + } + }], + body: { + type: "BlockStatement", + start: 37, + end: 39, + body: [] + } + }, + "(function (...rest: Array) {})": { + type: "ExpressionStatement", + start: 0, + end: 38, + expression: { + type: "FunctionExpression", + start: 1, + end: 37, + id: null, + generator: false, + expression: false, + params: [{ + type: "RestElement", + start: 11, + end: 33, + argument: { + type: "Identifier", + start: 14, + end: 18, + name: "rest" + }, + typeAnnotation: { + type: "TypeAnnotation", + start: 18, + end: 33, + typeAnnotation: { + type: "GenericTypeAnnotation", + start: 20, + end: 33, + typeParameters: { + type: "TypeParameterInstantiation", + start: 25, + end: 33, + params: [ + { + type: "NumberTypeAnnotation", + start: 26, + end: 32 + } + ] + }, + id: { + type: "Identifier", + start: 20, + end: 25, + name: "Array" + } + } + } + }], + body: { + type: "BlockStatement", + start: 35, + end: 37, + body: [] + } + } + }, + "((...rest: Array) => rest)": { + type: "ExpressionStatement", + start: 0, + end: 34, + expression: { + type: "ArrowFunctionExpression", + start: 1, + end: 33, + id: null, + generator: false, + expression: true, + params: [{ + type: "RestElement", + start: 2, + end: 9, + argument: { + type: "Identifier", + start: 5, + end: 9, + name: "rest" + }, + typeAnnotation: { + type: "TypeAnnotation", + start: 9, + end: 24, + typeAnnotation: { + type: "GenericTypeAnnotation", + start: 11, + end: 24, + typeParameters: { + type: "TypeParameterInstantiation", + start: 16, + end: 24, + params: [ + { + type: "NumberTypeAnnotation", + start: 17, + end: 23 + } + ] + }, + id: { + type: "Identifier", + start: 11, + end: 16, + name: "Array" + } + } + } + }], + body: { + type: "Identifier", + start: 29, + end: 33, + name: "rest" + } + } + }, + 'var a: Map >': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Map', + range: [7, 10], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 10 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [11, 17], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 17 } + } + }, { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [19, 24], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 24 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }], + range: [24, 32], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 32 } + } + }, + range: [19, 32], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 32 } + } + }], + range: [10, 34], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 34 } + } + }, + range: [7, 34], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 34 } + } + }, + range: [5, 34], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 34 } + } + }, + range: [4, 34], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 34 } + } + }, + init: null, + range: [4, 34], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 34 } + } + }], + kind: 'var', + range: [0, 34], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 34 } + } + }, + 'var a: Map>': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Map', + range: [7, 10], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 10 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [11, 17], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 17 } + } + }, { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [19, 24], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 24 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'StringTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }], + range: [24, 32], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 32 } + } + }, + range: [19, 32], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 32 } + } + }], + range: [10, 33], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 33 } + } + }, + range: [7, 33], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 33 } + } + }, + range: [5, 33], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 33 } + } + }, + range: [4, 33], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 33 } + } + }, + init: null, + range: [4, 33], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 33 } + } + }], + kind: 'var', + range: [0, 33], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 33 } + } + }, + 'var a: number[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NumberTypeAnnotation', + range: [7, 13], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 13 } + } + }, + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, + range: [5, 15], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 15 } + } + }, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }, + init: null, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }], + kind: 'var', + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + 'var a: ?string[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'StringTypeAnnotation', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + range: [8, 16], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + } + }, + range: [7, 16], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 16 } + } + }, + range: [5, 16], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 16 } + } + }, + range: [4, 16], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 16 } + } + }, + init: null, + range: [4, 16], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 16 } + } + }], + kind: 'var', + range: [0, 16], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + } + }, + 'var a: Promise[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Promise', + range: [7, 14], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'BooleanTypeAnnotation', + range: [15, 19], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + } + }], + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + range: [7, 20], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 20 } + } + }, + range: [7, 22], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 22 } + } + }, + range: [5, 22], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 22 } + } + }, + range: [4, 22], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 22 } + } + }, + init: null, + range: [4, 22], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 22 } + } + }], + kind: 'var', + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + 'var a:(...rest:Array) => number': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [33, 39], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 39 } + } + }, + rest: { + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'rest', + range: [10, 14], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 14 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Array', + range: [15, 20], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'NumberTypeAnnotation', + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }], + range: [20, 28], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 28 } + } + }, + range: [15, 28], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 28 } + } + }, + optional: false, + range: [10, 28], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 28 } + } + }, + typeParameters: null, + range: [6, 39], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 39 } + } + }, + range: [5, 39], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 39 } + } + }, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }, + init: null, + range: [4, 39], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 39 } + } + }], + kind: 'var', + range: [0, 39], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 39 } + } + }, + 'var identity: (x: T) => T': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'identity', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [21, 22], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + } + }, + typeParameters: null, + range: [21, 22], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [18, 22], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 22 } + } + }], + returnType: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [27, 28], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + } + }, + typeParameters: null, + range: [27, 28], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }], + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + range: [14, 28], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 28 } + } + }, + range: [12, 28], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 28 } + } + }, + range: [4, 28], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 28 } + } + }, + init: null, + range: [4, 28], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 28 } + } + }], + kind: 'var', + range: [0, 28], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 28 } + } + }, + 'var identity: (x: T, ...y:T[]) => T': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'identity', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [21, 22], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + } + }, + typeParameters: null, + range: [21, 22], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + } + }, + optional: false, + range: [18, 22], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 22 } + } + }], + returnType: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [37, 38], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 38 } + } + }, + typeParameters: null, + range: [37, 38], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 38 } + } + }, + rest: { + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'y', + range: [27, 28], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + } + }, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }, + typeParameters: null, + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }, + range: [29, 32], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 32 } + } + }, + optional: false, + range: [27, 32], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 32 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }], + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + range: [14, 38], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 38 } + } + }, + range: [12, 38], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 38 } + } + }, + range: [4, 38], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 38 } + } + }, + init: null, + range: [4, 38], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 38 } + } + }], + kind: 'var', + range: [0, 38], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 38 } + } + }, + 'import type foo from "bar";': { + type: 'ImportDeclaration', + specifiers: [{ + type: 'ImportDefaultSpecifier', + local: { + type: 'Identifier', + name: 'foo', + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }, + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }], + source: { + type: 'Literal', + value: 'bar', + raw: '"bar"', + range: [21, 26], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 26 } + } + }, + isType: true, + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + 'import type {foo, bar} from "baz";': { + type: 'ImportDeclaration', + specifiers: [{ + type: 'ImportSpecifier', + local: { + type: 'Identifier', + name: 'foo', + range: [13, 16], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 16 } + } + }, + imported: { + type: 'Identifier', + name: 'foo', + range: [13, 16], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 16 } + } + }, + range: [13, 16], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 16 } + } + }, { + type: 'ImportSpecifier', + local: { + type: 'Identifier', + name: 'bar', + range: [18, 21], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 21 } + } + }, + imported: { + type: 'Identifier', + name: 'bar', + range: [18, 21], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 21 } + } + }, + range: [18, 21], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 21 } + } + }], + source: { + type: 'Literal', + value: 'baz', + raw: '"baz"', + range: [28, 33], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 33 } + } + }, + isType: true, + range: [0, 34], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 34 } + } + }, + 'import type {foo as bar} from "baz";': { + type: 'ImportDeclaration', + specifiers: [{ + type: 'ImportSpecifier', + imported: { + type: 'Identifier', + name: 'foo', + range: [13, 16], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 16 } + } + }, + local: { + type: 'Identifier', + name: 'bar', + range: [20, 23], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + } + }, + range: [13, 23], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 23 } + } + }], + source: { + type: 'Literal', + value: 'baz', + raw: '"baz"', + range: [30, 35], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 35 } + } + }, + isType: true, + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'import type from "foo";': { + type: 'ImportDeclaration', + specifiers: [{ + type: 'ImportDefaultSpecifier', + local: { + type: 'Identifier', + name: 'type', + range: [7, 11], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 11 } + } + }, + range: [7, 11], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 11 } + } + }], + source: { + type: 'Literal', + value: 'foo', + raw: '"foo"', + range: [17, 22], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 22 } + } + }, + isType: false, + range: [0, 23], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 23 } + } + }, + 'import type, {foo} from "bar";': { + type: 'ImportDeclaration', + specifiers: [{ + type: 'ImportDefaultSpecifier', + local: { + type: 'Identifier', + name: 'type', + range: [7, 11], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 11 } + } + }, + range: [7, 11], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 11 } + } + }, { + type: 'ImportSpecifier', + local: { + type: 'Identifier', + name: 'foo', + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + imported: { + type: 'Identifier', + name: 'foo', + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }], + source: { + type: 'Literal', + value: 'bar', + raw: '"bar"', + range: [24, 29], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 29 } + } + }, + isType: false, + range: [0, 30], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 30 } + } + }, + 'import type * as namespace from "bar";': { + type: 'ImportDeclaration', + specifiers: [{ + type: 'ImportNamespaceSpecifier', + local: { + type: 'Identifier', + name: 'namespace', + range: [17, 26], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 26 } + } + }, + range: [12, 26], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 26 } + } + }], + source: { + type: 'Literal', + value: 'bar', + raw: '"bar"', + range: [32, 37], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 37 } + } + }, + isType: true, + range: [0, 38], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 38 } + } + }, + }, + 'Array Types': { + 'var a: number[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NumberTypeAnnotation', + range: [7, 13], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 13 } + } + }, + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, + range: [5, 15], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 15 } + } + }, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }, + init: null, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }], + kind: 'var', + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + 'var a: ?number[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NumberTypeAnnotation', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + range: [8, 16], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + } + }, + range: [7, 16], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 16 } + } + }, + range: [5, 16], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 16 } + } + }, + range: [4, 16], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 16 } + } + }, + init: null, + range: [4, 16], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 16 } + } + }], + kind: 'var', + range: [0, 16], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + } + }, + 'var a: (?number)[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [9, 15], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 15 } + } + }, + range: [8, 15], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 15 } + } + }, + range: [7, 18], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + } + }, + range: [5, 18], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 18 } + } + }, + range: [4, 18], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 18 } + } + }, + init: null, + range: [4, 18], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 18 } + } + }], + kind: 'var', + range: [0, 18], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 18 } + } + }, + 'var a: () => number[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NumberTypeAnnotation', + range: [13, 19], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 19 } + } + }, + range: [13, 21], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 21 } + } + }, + typeParameters: null, + range: [7, 21], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 21 } + } + }, + range: [5, 21], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 21 } + } + }, + range: [4, 21], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 21 } + } + }, + init: null, + range: [4, 21], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 21 } + } + }], + kind: 'var', + range: [0, 21], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 21 } + } + }, + 'var a: (() => number)[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + range: [8, 20], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 20 } + } + }, + range: [7, 23], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 23 } + } + }, + range: [5, 23], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 23 } + } + }, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }, + init: null, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }], + kind: 'var', + range: [0, 23], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 23 } + } + }, + 'var a: typeof A[]': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'TypeofTypeAnnotation', + argument: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'A', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, + range: [7, 17], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 17 } + } + }, + range: [5, 17], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 17 } + } + }, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }, + init: null, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }], + kind: 'var', + range: [0, 17], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 17 } + } + }, + }, + 'Tuples': { + 'var a : [] = [];': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TupleTypeAnnotation', + types: [], + range: [8, 10], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 10 } + } + }, + range: [6, 10], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 10 } + } + }, + range: [4, 10], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 10 } + } + }, + init: { + type: 'ArrayExpression', + elements: [], + range: [13, 15], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 15 } + } + }, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }], + kind: 'var', + range: [0, 16], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + } + }, + 'var a : [Foo] = [foo];': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TupleTypeAnnotation', + types: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Foo', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, + typeParameters: null, + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }], + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }, + range: [9, 15], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 15 } + } + }], + range: [8, 16], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + } + }, + range: [6, 16], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 16 } + } + }, + range: [4, 16], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 16 } + } + }, + init: { + type: 'ArrayExpression', + elements: [{ + type: 'Identifier', + name: 'foo', + range: [20, 23], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + } + }], + range: [19, 24], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 24 } + } + }, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }], + kind: 'var', + range: [0, 25], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 25 } + } + }, + 'var a : [number,] = [123,];': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TupleTypeAnnotation', + types: [{ + type: 'NumberTypeAnnotation', + range: [9, 15], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 15 } + } + }], + range: [8, 17], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 17 } + } + }, + range: [6, 17], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 17 } + } + }, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }, + init: { + type: 'ArrayExpression', + elements: [{ + type: 'Literal', + value: 123, + raw: '123', + range: [21, 24], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 24 } + } + }], + range: [20, 26], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 26 } + } + }, + range: [4, 26], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 26 } + } + }], + kind: 'var', + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + 'var a : [number, string] = [123, "duck"];': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TupleTypeAnnotation', + types: [{ + type: 'NumberTypeAnnotation', + range: [9, 15], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 15 } + } + }, { + type: 'StringTypeAnnotation', + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }], + range: [8, 24], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 24 } + } + }, + range: [6, 24], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 24 } + } + }, + range: [4, 24], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 24 } + } + }, + init: { + type: 'ArrayExpression', + elements: [{ + type: 'Literal', + value: 123, + raw: '123', + range: [28, 31], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 31 } + } + }, { + type: 'Literal', + value: 'duck', + raw: '"duck"', + range: [33, 39], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 39 } + } + }], + range: [27, 40], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 40 } + } + }, + range: [4, 40], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 40 } + } + }], + kind: 'var', + range: [0, 41], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 41 } + } + }, + }, + 'Type Alias': { + 'type FBID = number;': { + type: 'TypeAlias', + id: { + type: 'Identifier', + name: 'FBID', + range: [5, 9], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 9 } + } + }, + typeParameters: null, + right: { + type: 'NumberTypeAnnotation', + range: [12, 18], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 18 } + } + }, + range: [0, 19], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 19 } + } + }, + 'type Foo = Bar': { + type: 'TypeAlias', + id: { + type: 'Identifier', + name: 'Foo', + range: [5, 8], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 8 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [9, 10], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 10 } + } + }], + range: [8, 11], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 11 } + } + }, + right: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Bar', + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }, + typeParameters: null, + range: [18, 19], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + } + }], + range: [17, 20], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 20 } + } + }, + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + range: [0, 20], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 20 } + } + }, + 'export type Foo = number;': { + type: 'ExportDeclaration', + 'default': false, + declaration: { + type: 'TypeAlias', + id: { + type: 'Identifier', + name: 'Foo', + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + right: { + type: 'NumberTypeAnnotation', + range: [18, 24], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 24 } + } + }, + range: [7, 25], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 25 } + } + }, + specifiers: null, + source: null, + range: [0, 25], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 25 } + } + }, + }, + 'Interfaces (module and script)': { + 'interface A {}': { + type: 'InterfaceDeclaration', + id: { + type: 'Identifier', + name: 'A', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [], + range: [12, 14], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 14 } + } + }, + 'extends': [], + range: [0, 14], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 14 } + } + }, + 'interface A extends B {}': { + type: 'InterfaceDeclaration', + id: { + type: 'Identifier', + name: 'A', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [], + range: [22, 24], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 24 } + } + }, + 'extends': [{ + type: 'InterfaceExtends', + id: { + type: 'Identifier', + name: 'B', + range: [20, 21], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 21 } + } + }, + typeParameters: null, + range: [20, 21], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 21 } + } + }], + range: [0, 24], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 24 } + } + }, + 'interface A extends B, C {}': { + type: 'InterfaceDeclaration', + id: { + type: 'Identifier', + name: 'A', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }], + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [], + range: [34, 36], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 36 } + } + }, + 'extends': [{ + type: 'InterfaceExtends', + id: { + type: 'Identifier', + name: 'B', + range: [23, 24], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 24 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [25, 26], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + } + }, + typeParameters: null, + range: [25, 26], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + } + }], + range: [24, 27], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 27 } + } + }, + range: [23, 27], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 27 } + } + }, { + type: 'InterfaceExtends', + id: { + type: 'Identifier', + name: 'C', + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [31, 32], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 32 } + } + }, + typeParameters: null, + range: [31, 32], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 32 } + } + }], + range: [30, 33], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 33 } + } + }, + range: [29, 33], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 33 } + } + }], + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'interface A { foo: () => number; }': { + type: 'InterfaceDeclaration', + id: { + type: 'Identifier', + name: 'A', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'foo', + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }, + typeParameters: null, + range: [19, 31], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 31 } + } + }, + optional: false, + range: [14, 31], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 31 } + } + }], + indexers: [], + callProperties: [], + range: [12, 34], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 34 } + } + }, + 'extends': [], + range: [0, 34], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 34 } + } + }, + 'interface Dictionary { [index: string]: string; length: number; }': { + type: 'InterfaceDeclaration', + id: { + type: 'Identifier', + name: 'Dictionary', + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'length', + range: [48, 54], + loc: { + start: { line: 1, column: 48 }, + end: { line: 1, column: 54 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [56, 62], + loc: { + start: { line: 1, column: 56 }, + end: { line: 1, column: 62 } + } + }, + optional: false, + range: [48, 62], + loc: { + start: { line: 1, column: 48 }, + end: { line: 1, column: 62 } + } + }], + indexers: [{ + type: 'ObjectTypeIndexer', + id: { + type: 'Identifier', + name: 'index', + range: [24, 29], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 29 } + } + }, + key: { + type: 'StringTypeAnnotation', + range: [31, 37], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 37 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [40, 46], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 46 } + } + }, + range: [23, 46], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 46 } + } + }], + callProperties: [], + range: [21, 65], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 65 } + } + }, + 'extends': [], + range: [0, 65], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 65 } + } + }, + 'class Foo implements Bar {}': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [], + range: [25, 27], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 27 } + } + }, + 'implements': [{ + type: 'ClassImplements', + id: { + type: 'Identifier', + name: 'Bar', + range: [21, 24], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 24 } + } + }, + typeParameters: null, + range: [21, 24], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 24 } + } + }], + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + 'class Foo extends Bar implements Bat, Man {}': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: { + type: 'Identifier', + name: 'Bar', + range: [18, 21], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 21 } + } + }, + body: { + type: 'ClassBody', + body: [], + range: [50, 52], + loc: { + start: { line: 1, column: 50 }, + end: { line: 1, column: 52 } + } + }, + 'implements': [{ + type: 'ClassImplements', + id: { + type: 'Identifier', + name: 'Bat', + range: [33, 36], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 36 } + } + }, + typeParameters: null, + range: [33, 36], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 36 } + } + }, { + type: 'ClassImplements', + id: { + type: 'Identifier', + name: 'Man', + range: [38, 41], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 41 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'NumberTypeAnnotation', + range: [42, 48], + loc: { + start: { line: 1, column: 42 }, + end: { line: 1, column: 48 } + } + }], + range: [41, 49], + loc: { + start: { line: 1, column: 41 }, + end: { line: 1, column: 49 } + } + }, + range: [38, 49], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 49 } + } + }], + range: [0, 52], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 52 } + } + }, + 'class Foo extends class Bar implements Bat {} {}': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: { + type: 'ClassExpression', + id: { + type: 'Identifier', + name: 'Bar', + range: [24, 27], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 27 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [], + range: [43, 45], + loc: { + start: { line: 1, column: 43 }, + end: { line: 1, column: 45 } + } + }, + 'implements': [{ + type: 'ClassImplements', + id: { + type: 'Identifier', + name: 'Bat', + range: [39, 42], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 42 } + } + }, + typeParameters: null, + range: [39, 42], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 42 } + } + }], + range: [18, 45], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 45 } + } + }, + body: { + type: 'ClassBody', + body: [], + range: [46, 48], + loc: { + start: { line: 1, column: 46 }, + end: { line: 1, column: 48 } + } + }, + range: [0, 48], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 48 } + } + }, + 'class Foo extends class Bar implements Bat {} implements Man {}': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'Foo', + range: [6, 9], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 9 } + } + }, + superClass: { + type: 'ClassExpression', + id: { + type: 'Identifier', + name: 'Bar', + range: [24, 27], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 27 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [], + range: [43, 45], + loc: { + start: { line: 1, column: 43 }, + end: { line: 1, column: 45 } + } + }, + 'implements': [{ + type: 'ClassImplements', + id: { + type: 'Identifier', + name: 'Bat', + range: [39, 42], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 42 } + } + }, + typeParameters: null, + range: [39, 42], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 42 } + } + }], + range: [18, 45], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 45 } + } + }, + body: { + type: 'ClassBody', + body: [], + range: [61, 63], + loc: { + start: { line: 1, column: 61 }, + end: { line: 1, column: 63 } + } + }, + 'implements': [{ + type: 'ClassImplements', + id: { + type: 'Identifier', + name: 'Man', + range: [57, 60], + loc: { + start: { line: 1, column: 57 }, + end: { line: 1, column: 60 } + } + }, + typeParameters: null, + range: [57, 60], + loc: { + start: { line: 1, column: 57 }, + end: { line: 1, column: 60 } + } + }], + range: [0, 63], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 63 } + } + }, + }, + 'Type Grouping': { + 'var a: (number)': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + range: [5, 15], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 15 } + } + }, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }, + init: null, + range: [4, 15], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 15 } + } + }], + kind: 'var', + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + 'var a: (() => number) | () => string': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'UnionTypeAnnotation', + types: [{ + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + range: [8, 20], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 20 } + } + }, { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'StringTypeAnnotation', + range: [30, 36], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 36 } + } + }, + typeParameters: null, + range: [24, 36], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 36 } + } + }], + range: [7, 36], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 36 } + } + }, + range: [5, 36], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 36 } + } + }, + range: [4, 36], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 36 } + } + }, + init: null, + range: [4, 36], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 36 } + } + }], + kind: 'var', + range: [0, 36], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 36 } + } + }, + 'var a: number & (string | bool)': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'IntersectionTypeAnnotation', + types: [{ + type: 'NumberTypeAnnotation', + range: [7, 13], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 13 } + } + }, { + type: 'UnionTypeAnnotation', + types: [{ + type: 'StringTypeAnnotation', + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }, { + type: 'BooleanTypeAnnotation', + range: [26, 30], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 30 } + } + }], + range: [17, 30], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 30 } + } + }], + range: [7, 31], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 31 } + } + }, + range: [5, 31], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 31 } + } + }, + range: [4, 31], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 31 } + } + }, + init: null, + range: [4, 31], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 31 } + } + }], + kind: 'var', + range: [0, 31], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 31 } + } + }, + 'var a: (typeof A)': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TypeofTypeAnnotation', + argument: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'A', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + typeParameters: null, + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + range: [8, 16], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + } + }, + range: [5, 17], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 17 } + } + }, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }, + init: null, + range: [4, 17], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 17 } + } + }], + kind: 'var', + range: [0, 17], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 17 } + } + }, + }, + 'Call Properties': { + 'var a : { (): number }': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [{ + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }], + range: [8, 22], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + } + }, + range: [6, 22], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 22 } + } + }, + range: [4, 22], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 22 } + } + }, + init: null, + range: [4, 22], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 22 } + } + }], + kind: 'var', + range: [0, 22], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + } + }, + 'var a : { (): number; }': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [{ + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }], + range: [8, 23], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 23 } + } + }, + range: [6, 23], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 23 } + } + }, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }, + init: null, + range: [4, 23], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 23 } + } + }], + kind: 'var', + range: [0, 23], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 23 } + } + }, + 'var a : { (): number; y: string; (x: string): string }': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'y', + range: [22, 23], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }, + optional: false, + range: [22, 31], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 31 } + } + }], + indexers: [], + callProperties: [{ + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [14, 20], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }, { + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [34, 35], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 35 } + } + }, + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [37, 43], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 43 } + } + }, + optional: false, + range: [34, 43], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 43 } + } + }], + returnType: { + type: 'StringTypeAnnotation', + range: [46, 52], + loc: { + start: { line: 1, column: 46 }, + end: { line: 1, column: 52 } + } + }, + typeParameters: null, + range: [33, 52], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 52 } + } + }, + range: [33, 52], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 52 } + } + }], + range: [8, 54], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 54 } + } + }, + range: [6, 54], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 54 } + } + }, + range: [4, 54], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 54 } + } + }, + init: null, + range: [4, 54], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 54 } + } + }], + kind: 'var', + range: [0, 54], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 54 } + } + }, + 'var a : { (x: T): number; }': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [{ + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: null, + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + optional: false, + range: [14, 18], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 18 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [21, 27], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 27 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [11, 12], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 12 } + } + }], + range: [10, 13], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 13 } + } + }, + range: [10, 27], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 27 } + } + }, + range: [10, 27], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 27 } + } + }], + range: [8, 30], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 30 } + } + }, + range: [6, 30], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 30 } + } + }, + range: [4, 30], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 30 } + } + }, + init: null, + range: [4, 30], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 30 } + } + }], + kind: 'var', + range: [0, 30], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 30 } + } + }, + 'interface A { (): number; }': { + type: 'InterfaceDeclaration', + id: { + type: 'Identifier', + name: 'A', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [{ + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [18, 24], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 24 } + } + }, + typeParameters: null, + range: [14, 24], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 24 } + } + }, + 'static': false, + range: [14, 24], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 24 } + } + }], + range: [12, 27], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 27 } + } + }, + 'extends': [], + range: [0, 27], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 27 } + } + }, + }, + 'String Literal Types': { + 'function createElement(tagName: "div"): HTMLDivElement {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'createElement', + range: [9, 22], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 22 } + } + }, + params: [{ + type: 'Identifier', + name: 'tagName', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'StringLiteralTypeAnnotation', + value: 'div', + raw: '"div"', + range: [32, 37], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 37 } + } + }, + range: [30, 37], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 37 } + } + }, + range: [23, 37], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 37 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [55, 57], + loc: { + start: { line: 1, column: 55 }, + end: { line: 1, column: 57 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'HTMLDivElement', + range: [40, 54], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 54 } + } + }, + typeParameters: null, + range: [40, 54], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 54 } + } + }, + range: [38, 54], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 54 } + } + }, + range: [0, 57], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 57 } + } + }, + 'function createElement(tagName: \'div\'): HTMLDivElement {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'createElement', + range: [9, 22], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 22 } + } + }, + params: [{ + type: 'Identifier', + name: 'tagName', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'StringLiteralTypeAnnotation', + value: 'div', + raw: '\'div\'', + range: [32, 37], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 37 } + } + }, + range: [30, 37], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 37 } + } + }, + range: [23, 37], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 37 } + } + }], + body: { + type: 'BlockStatement', + body: [], + range: [55, 57], + loc: { + start: { line: 1, column: 55 }, + end: { line: 1, column: 57 } + } + }, + generator: false, + expression: false, + returnType: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'HTMLDivElement', + range: [40, 54], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 54 } + } + }, + typeParameters: null, + range: [40, 54], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 54 } + } + }, + range: [38, 54], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 54 } + } + }, + range: [0, 57], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 57 } + } + }, + }, + 'Qualified Generic Type': { + 'var a : A.B': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'QualifiedTypeIdentifier', + qualification: { + type: 'Identifier', + name: 'A', + range: [8, 9], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 9 } + } + }, + id: { + type: 'Identifier', + name: 'B', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + range: [8, 11], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: null, + range: [8, 11], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 11 } + } + }, + range: [6, 11], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 11 } + } + }, + range: [4, 11], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 11 } + } + }, + init: null, + range: [4, 11], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 11 } + } + }], + kind: 'var', + range: [0, 11], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + } + }, + 'var a : A.B.C': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'QualifiedTypeIdentifier', + qualification: { + type: 'QualifiedTypeIdentifier', + qualification: { + type: 'Identifier', + name: 'A', + range: [8, 9], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 9 } + } + }, + id: { + type: 'Identifier', + name: 'B', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + range: [8, 11], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 11 } + } + }, + id: { + type: 'Identifier', + name: 'C', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }, + range: [8, 13], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 13 } + } + }, + typeParameters: null, + range: [8, 13], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 13 } + } + }, + range: [6, 13], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 13 } + } + }, + range: [4, 13], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 13 } + } + }, + init: null, + range: [4, 13], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 13 } + } + }], + kind: 'var', + range: [0, 13], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 13 } + } + }, + 'var a : A.B': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'QualifiedTypeIdentifier', + qualification: { + type: 'Identifier', + name: 'A', + range: [8, 9], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 9 } + } + }, + id: { + type: 'Identifier', + name: 'B', + range: [10, 11], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + } + }, + range: [8, 11], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 11 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }, + typeParameters: null, + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }], + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }, + range: [6, 14], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 14 } + } + }, + range: [4, 14], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 14 } + } + }, + init: null, + range: [4, 14], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 14 } + } + }], + kind: 'var', + range: [0, 14], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 14 } + } + }, + 'var a : typeof A.B': { + type: 'VariableDeclaration', + declarations: [{ + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: 'a', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'TypeofTypeAnnotation', + argument: { + type: 'GenericTypeAnnotation', + id: { + type: 'QualifiedTypeIdentifier', + qualification: { + type: 'Identifier', + name: 'A', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + id: { + type: 'Identifier', + name: 'B', + range: [17, 18], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + } + }, + range: [15, 18], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [19, 20], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + } + }, + typeParameters: null, + range: [19, 20], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + } + }], + range: [18, 21], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 21 } + } + }, + range: [15, 21], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 21 } + } + }, + range: [8, 21], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 21 } + } + }, + range: [6, 21], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 21 } + } + }, + range: [4, 21], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 21 } + } + }, + init: null, + range: [4, 21], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 21 } + } + }], + kind: 'var', + range: [0, 21], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 21 } + } + }, + }, + 'Declare Statements': { + 'declare var foo': { + type: 'DeclareVariable', + id: { + type: 'Identifier', + name: 'foo', + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }, + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + 'declare var foo;': { + type: 'DeclareVariable', + id: { + type: 'Identifier', + name: 'foo', + range: [12, 15], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + } + }, + range: [0, 16], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + } + }, + 'declare function foo(): void': { + type: 'DeclareFunction', + id: { + type: 'Identifier', + name: 'foo', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'VoidTypeAnnotation', + range: [24, 28], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 28 } + } + }, + typeParameters: null, + range: [20, 28], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 28 } + } + }, + range: [20, 28], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 28 } + } + }, + range: [17, 28], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 28 } + } + }, + range: [0, 28], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 28 } + } + }, + 'declare function foo(): void;': { + type: 'DeclareFunction', + id: { + type: 'Identifier', + name: 'foo', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'VoidTypeAnnotation', + range: [24, 28], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 28 } + } + }, + typeParameters: null, + range: [20, 28], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 28 } + } + }, + range: [20, 28], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 28 } + } + }, + range: [17, 28], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 28 } + } + }, + range: [0, 29], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 29 } + } + }, + 'declare function foo(): void;': { + type: 'DeclareFunction', + id: { + type: 'Identifier', + name: 'foo', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'VoidTypeAnnotation', + range: [27, 31], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 31 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [21, 22], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + } + }], + range: [20, 23], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + } + }, + range: [20, 31], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 31 } + } + }, + range: [20, 31], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 31 } + } + }, + range: [17, 31], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 31 } + } + }, + range: [0, 32], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 32 } + } + }, + 'declare function foo(x: number, y: string): void;': { + type: 'DeclareFunction', + id: { + type: 'Identifier', + name: 'foo', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'x', + range: [21, 22], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + } + }, + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [24, 30], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 30 } + } + }, + optional: false, + range: [21, 30], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 30 } + } + }, { + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'y', + range: [32, 33], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 33 } + } + }, + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [35, 41], + loc: { + start: { line: 1, column: 35 }, + end: { line: 1, column: 41 } + } + }, + optional: false, + range: [32, 41], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 41 } + } + }], + returnType: { + type: 'VoidTypeAnnotation', + range: [44, 48], + loc: { + start: { line: 1, column: 44 }, + end: { line: 1, column: 48 } + } + }, + typeParameters: null, + range: [20, 48], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 48 } + } + }, + range: [20, 48], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 48 } + } + }, + range: [17, 48], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 48 } + } + }, + range: [0, 49], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 49 } + } + }, + 'declare class A {}': { + type: 'DeclareClass', + id: { + type: 'Identifier', + name: 'A', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [], + range: [16, 18], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 18 } + } + }, + 'extends': [], + range: [0, 18], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 18 } + } + }, + 'declare class A extends B { x: number }': { + type: 'DeclareClass', + id: { + type: 'Identifier', + name: 'A', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + range: [16, 17], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + } + }], + range: [15, 18], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + } + }, + body: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'x', + range: [34, 35], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 35 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [37, 43], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 43 } + } + }, + optional: false, + range: [34, 43], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 43 } + } + }], + indexers: [], + callProperties: [], + range: [32, 45], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 45 } + } + }, + 'extends': [{ + type: 'InterfaceExtends', + id: { + type: 'Identifier', + name: 'B', + range: [27, 28], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + } + }, + typeParameters: { + type: 'TypeParameterInstantiation', + params: [{ + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'T', + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }, + typeParameters: null, + range: [29, 30], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 30 } + } + }], + range: [28, 31], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 31 } + } + }, + range: [27, 31], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 31 } + } + }], + range: [0, 45], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 45 } + } + }, + 'declare class A { static foo(): number; static x : string }': { + type: 'DeclareClass', + id: { + type: 'Identifier', + name: 'A', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'foo', + range: [25, 28], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 28 } + } + }, + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [32, 38], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 38 } + } + }, + typeParameters: null, + range: [18, 38], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 38 } + } + }, + optional: false, + 'static': true, + range: [18, 38], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 38 } + } + }, { + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'x', + range: [47, 48], + loc: { + start: { line: 1, column: 47 }, + end: { line: 1, column: 48 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [51, 57], + loc: { + start: { line: 1, column: 51 }, + end: { line: 1, column: 57 } + } + }, + optional: false, + 'static': true, + range: [40, 57], + loc: { + start: { line: 1, column: 40 }, + end: { line: 1, column: 57 } + } + }], + indexers: [], + callProperties: [], + range: [16, 59], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 59 } + } + }, + 'extends': [], + range: [0, 59], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 59 } + } + }, + 'declare class A { static [ indexer: number]: string }': { + type: 'DeclareClass', + id: { + type: 'Identifier', + name: 'A', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [{ + type: 'ObjectTypeIndexer', + id: { + type: 'Identifier', + name: 'indexer', + range: [27, 34], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 34 } + } + }, + key: { + type: 'NumberTypeAnnotation', + range: [36, 42], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 42 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [45, 51], + loc: { + start: { line: 1, column: 45 }, + end: { line: 1, column: 51 } + } + }, + 'static': true, + range: [18, 51], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 51 } + } + }], + callProperties: [], + range: [16, 53], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 53 } + } + }, + 'extends': [], + range: [0, 53], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 53 } + } + }, + 'declare class A { static () : number }': { + type: 'DeclareClass', + id: { + type: 'Identifier', + name: 'A', + range: [14, 15], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [], + indexers: [], + callProperties: [{ + type: 'ObjectTypeCallProperty', + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [30, 36], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 36 } + } + }, + typeParameters: null, + range: [25, 36], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 36 } + } + }, + 'static': true, + range: [18, 36], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 36 } + } + }], + range: [16, 38], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 38 } + } + }, + 'extends': [], + range: [0, 38], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 38 } + } + }, + }, + 'Declare Module': { + 'declare module A {}': { + type: 'DeclareModule', + id: { + type: 'Identifier', + name: 'A', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + body: { + type: 'BlockStatement', + body: [], + range: [17, 19], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 19 } + } + }, + range: [0, 19], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 19 } + } + }, + 'declare module "./a/b.js" {}': { + type: 'DeclareModule', + id: { + type: 'Literal', + value: './a/b.js', + raw: '"./a/b.js"', + range: [15, 25], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 25 } + } + }, + body: { + type: 'BlockStatement', + body: [], + range: [26, 28], + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 28 } + } + }, + range: [0, 28], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 28 } + } + }, + 'declare module A { declare var x: number; }': { + type: 'DeclareModule', + id: { + type: 'Identifier', + name: 'A', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + body: { + type: 'BlockStatement', + body: [{ + type: 'DeclareVariable', + id: { + type: 'Identifier', + name: 'x', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [34, 40], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 40 } + } + }, + range: [32, 40], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 40 } + } + }, + range: [31, 40], + loc: { + start: { line: 1, column: 31 }, + end: { line: 1, column: 40 } + } + }, + range: [19, 41], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 41 } + } + }], + range: [17, 43], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 43 } + } + }, + range: [0, 43], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 43 } + } + }, + 'declare module A { declare function foo(): number; }': { + type: 'DeclareModule', + id: { + type: 'Identifier', + name: 'A', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + body: { + type: 'BlockStatement', + body: [{ + type: 'DeclareFunction', + id: { + type: 'Identifier', + name: 'foo', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [43, 49], + loc: { + start: { line: 1, column: 43 }, + end: { line: 1, column: 49 } + } + }, + typeParameters: null, + range: [39, 49], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 49 } + } + }, + range: [39, 49], + loc: { + start: { line: 1, column: 39 }, + end: { line: 1, column: 49 } + } + }, + range: [36, 49], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 49 } + } + }, + range: [19, 50], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 50 } + } + }], + range: [17, 52], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 52 } + } + }, + range: [0, 52], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 52 } + } + }, + 'declare module A { declare class B { foo(): number; } }': { + type: 'DeclareModule', + id: { + type: 'Identifier', + name: 'A', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, + body: { + type: 'BlockStatement', + body: [{ + type: 'DeclareClass', + id: { + type: 'Identifier', + name: 'B', + range: [33, 34], + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 34 } + } + }, + typeParameters: null, + body: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'foo', + range: [37, 40], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 40 } + } + }, + value: { + type: 'FunctionTypeAnnotation', + params: [], + returnType: { + type: 'NumberTypeAnnotation', + range: [44, 50], + loc: { + start: { line: 1, column: 44 }, + end: { line: 1, column: 50 } + } + }, + typeParameters: null, + range: [37, 50], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 50 } + } + }, + optional: false, + range: [37, 50], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 50 } + } + }], + indexers: [], + callProperties: [], + range: [35, 53], + loc: { + start: { line: 1, column: 35 }, + end: { line: 1, column: 53 } + } + }, + 'extends': [], + range: [19, 53], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 53 } + } + }], + range: [17, 55], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 55 } + } + }, + range: [0, 55], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 55 } + } + }, + }, + 'Typecasts': { + '(xxx: number)': { + type: 'ExpressionStatement', + expression: { + type: 'TypeCastExpression', + expression: { + type: 'Identifier', + name: 'xxx', + range: [1, 4], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 4 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [6, 12], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 12 } + } + }, + range: [4, 12], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 12 } + } + }, + range: [1, 12], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 12 } + } + }, + range: [0, 13], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 13 } + } + }, + '({xxx: 0, yyy: "hey"}: {xxx: number; yyy: string})': { + type: 'ExpressionStatement', + expression: { + type: 'TypeCastExpression', + expression: { + type: 'ObjectExpression', + properties: [{ + type: 'Property', + key: { + type: 'Identifier', + name: 'xxx', + range: [2, 5], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 5 } + } + }, + value: { + type: 'Literal', + value: 0, + raw: '0', + range: [7, 8], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + } + }, + kind: 'init', + method: false, + shorthand: false, + computed: false, + range: [2, 8], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 8 } + } + }, { + type: 'Property', + key: { + type: 'Identifier', + name: 'yyy', + range: [10, 13], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 13 } + } + }, + value: { + type: 'Literal', + value: 'hey', + raw: '"hey"', + range: [15, 20], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 20 } + } + }, + kind: 'init', + method: false, + shorthand: false, + computed: false, + range: [10, 20], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 20 } + } + }], + range: [1, 21], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 21 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [{ + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'xxx', + range: [24, 27], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 27 } + } + }, + value: { + type: 'NumberTypeAnnotation', + range: [29, 35], + loc: { + start: { line: 1, column: 29 }, + end: { line: 1, column: 35 } + } + }, + optional: false, + range: [24, 35], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 35 } + } + }, { + type: 'ObjectTypeProperty', + key: { + type: 'Identifier', + name: 'yyy', + range: [37, 40], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 40 } + } + }, + value: { + type: 'StringTypeAnnotation', + range: [42, 48], + loc: { + start: { line: 1, column: 42 }, + end: { line: 1, column: 48 } + } + }, + optional: false, + range: [37, 48], + loc: { + start: { line: 1, column: 37 }, + end: { line: 1, column: 48 } + } + }], + indexers: [], + callProperties: [], + range: [23, 49], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 49 } + } + }, + range: [21, 49], + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 49 } + } + }, + range: [1, 49], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 49 } + } + }, + range: [0, 50], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 50 } + } + }, + '((xxx) => xxx + 1: (xxx: number) => number)': { + type: 'ExpressionStatement', + expression: { + type: 'TypeCastExpression', + expression: { + type: 'ArrowFunctionExpression', + id: null, + params: [{ + type: 'Identifier', + name: 'xxx', + range: [2, 5], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 5 } + } + }], + body: { + type: 'BinaryExpression', + operator: '+', + left: { + type: 'Identifier', + name: 'xxx', + range: [10, 13], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 13 } + } + }, + right: { + type: 'Literal', + value: 1, + raw: '1', + range: [16, 17], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + } + }, + range: [10, 17], + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 17 } + } + }, + generator: false, + expression: true, + range: [1, 17], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 17 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params: [{ + type: 'FunctionTypeParam', + name: { + type: 'Identifier', + name: 'xxx', + range: [20, 23], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + } + }, + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [25, 31], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 31 } + } + }, + optional: false, + range: [20, 31], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 31 } + } + }], + returnType: { + type: 'NumberTypeAnnotation', + range: [36, 42], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 42 } + } + }, + typeParameters: null, + range: [19, 42], + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 42 } + } + }, + range: [17, 42], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 42 } + } + }, + range: [1, 42], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 42 } + } + }, + range: [0, 43], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 43 } + } + }, + '((xxx: number), (yyy: string))': { + type: 'ExpressionStatement', + expression: { + type: 'SequenceExpression', + expressions: [{ + type: 'TypeCastExpression', + expression: { + type: 'Identifier', + name: 'xxx', + range: [2, 5], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 5 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [7, 13], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 13 } + } + }, + range: [5, 13], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 13 } + } + }, + range: [2, 13], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 13 } + } + }, { + type: 'TypeCastExpression', + expression: { + type: 'Identifier', + name: 'yyy', + range: [17, 20], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 20 } + } + }, + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'StringTypeAnnotation', + range: [22, 28], + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 28 } + } + }, + range: [20, 28], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 28 } + } + }, + range: [17, 28], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 28 } + } + }], + range: [1, 29], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 29 } + } + }, + range: [0, 30], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 30 } + } + }, + }, + 'Bounded Polymorphism': { + 'class A {}': { + type: 'ClassDeclaration', + id: { + type: 'Identifier', + name: 'A', + range: [6, 7], + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 7 } + } + }, + superClass: null, + body: { + type: 'ClassBody', + body: [], + range: [16, 18], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 18 } + } + }, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'GenericTypeAnnotation', + id: { + type: 'Identifier', + name: 'Foo', + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + typeParameters: null, + range: [11, 14], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 14 } + } + }, + range: [9, 14], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 14 } + } + }, + range: [8, 14], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + } + }], + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, + range: [0, 18], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 18 } + } + }, + 'function bar() {}': { + type: 'FunctionDeclaration', + id: { + type: 'Identifier', + name: 'bar', + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + params: [], + body: { + type: 'BlockStatement', + body: [], + range: [27, 29], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 29 } + } + }, + generator: false, + expression: false, + typeParameters: { + type: 'TypeParameterDeclaration', + params: [{ + type: 'Identifier', + name: 'T', + typeAnnotation: { + type: 'TypeAnnotation', + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + range: [17, 23], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 23 } + } + }, + range: [16, 23], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 23 } + } + }, + range: [14, 23], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 23 } + } + }, + range: [13, 23], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 23 } + } + }], + range: [12, 24], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 24 } + } + }, + range: [0, 29], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 29 } + } + }, + }, +}; + +if (typeof exports !== "undefined") { + var test = require("./driver.js").test; +} + +for (var ns in fbTestFixture) { + ns = fbTestFixture[ns]; + for (var code in ns) { + test(code, { + type: "Program", + body: [ns[code]] + }, { + ecmaVersion: 7, + plugins: { flow: true, jsx: true }, + features: { "es7.asyncFunctions": true }, + locations: true, + ranges: true + }); + } +} diff --git a/lib/acorn/test/tests-harmony.js b/vendor/acorn/test/tests-harmony.js similarity index 99% rename from lib/acorn/test/tests-harmony.js rename to vendor/acorn/test/tests-harmony.js index 3fde855cfb..c81fca1423 100644 --- a/lib/acorn/test/tests-harmony.js +++ b/vendor/acorn/test/tests-harmony.js @@ -6560,7 +6560,7 @@ test("class A {get() {}}", { end: {line: 1, column: 17} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 9}, @@ -6632,7 +6632,7 @@ test("class A { static get() {}}", { end: {line: 1, column: 25} } }, - kind: "", + kind: "method", static: true, loc: { start: {line: 1, column: 10}, @@ -7027,7 +7027,7 @@ test("class A {set(v) {};}", { end: {line: 1, column: 18} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 9}, @@ -7106,7 +7106,7 @@ test("class A { static set(v) {};}", { end: {line: 1, column: 26} } }, - kind: "", + kind: "method", static: true, loc: { start: {line: 1, column: 10}, @@ -7207,7 +7207,7 @@ test("class A {*gen(v) { yield v; }}", { end: {line: 1, column: 29} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 9}, @@ -7308,7 +7308,7 @@ test("class A { static *gen(v) { yield v; }}", { end: {line: 1, column: 37} } }, - kind: "", + kind: "method", static: true, loc: { start: {line: 1, column: 10}, @@ -7391,8 +7391,7 @@ test("\"use strict\"; (class A {constructor() { super() }})", { expression: { type: "CallExpression", callee: { - type: "Identifier", - name: "super", + type: "SuperExpression", loc: { start: {line: 1, column: 40}, end: {line: 1, column: 45} @@ -7421,7 +7420,7 @@ test("\"use strict\"; (class A {constructor() { super() }})", { end: {line: 1, column: 49} } }, - kind: "", + kind: "constructor", static: false, loc: { start: {line: 1, column: 24}, @@ -7454,6 +7453,36 @@ test("\"use strict\"; (class A {constructor() { super() }})", { locations: true }); +test("class A {'constructor'() {}}", { + type: "Program", + body: [{ + type: "ClassDeclaration", + id: {type: "Identifier", name: "A"}, + superClass: null, + body: { + type: "ClassBody", + body: [{ + type: "MethodDefinition", + computed: false, + key: {type: "Literal", value: "constructor"}, + static: false, + kind: "constructor", + value: { + type: "FunctionExpression", + id: null, + generator: false, + expression: false, + params: [], + body: { + type: "BlockStatement", + body: [] + } + } + }] + } + }] +}, {ecmaVersion: 6}); + test("class A {static foo() {}}", { type: "Program", body: [{ @@ -7499,7 +7528,7 @@ test("class A {static foo() {}}", { end: {line: 1, column: 24} } }, - kind: "", + kind: "method", static: true, loc: { start: {line: 1, column: 9}, @@ -7572,7 +7601,7 @@ test("class A {foo() {} static bar() {}}", { end: {line: 1, column: 17} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 9}, @@ -7609,7 +7638,7 @@ test("class A {foo() {} static bar() {}}", { end: {line: 1, column: 33} } }, - kind: "", + kind: "method", static: true, loc: { start: {line: 1, column: 18}, @@ -7693,8 +7722,7 @@ test("\"use strict\"; (class A { static constructor() { super() }})", { expression: { type: "CallExpression", callee: { - type: "Identifier", - name: "super", + type: "SuperExpression", loc: { start: {line: 1, column: 48}, end: {line: 1, column: 53} @@ -7723,7 +7751,7 @@ test("\"use strict\"; (class A { static constructor() { super() }})", { end: {line: 1, column: 57} } }, - kind: "", + kind: "method", static: true, loc: { start: {line: 1, column: 25}, @@ -7802,7 +7830,7 @@ test("class A { foo() {} bar() {}}", { end: {line: 1, column: 18} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 10}, @@ -7839,7 +7867,7 @@ test("class A { foo() {} bar() {}}", { end: {line: 1, column: 27} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 19}, @@ -8450,7 +8478,7 @@ test("class A { static [foo]() {} }", { }, name: "foo" }, - kind: "", + kind: "method", value: { type: "FunctionExpression", loc: { @@ -8717,7 +8745,7 @@ test("class A { foo() {} get foo() {} }",{ }, name: "foo" }, - kind: "", + kind: "method", value: { type: "FunctionExpression", loc: { @@ -9582,7 +9610,7 @@ test("class A {[x]() {}}", { }, name: "x" }, - kind: "", + kind: "method", value: { type: "FunctionExpression", loc: { @@ -10324,7 +10352,7 @@ test("(class {f({x} = {x: 10}) {}})", { end: {line: 1, column: 27} } }, - kind: "", + kind: "method", static: false, loc: { start: {line: 1, column: 8}, @@ -14947,7 +14975,7 @@ test("class A { static() {} }", { name: "static" }, static: false, - kind: "", + kind: "method", value: { type: "FunctionExpression", range: [16, 21], @@ -15044,7 +15072,7 @@ test("class A { *static() {} }", { name: "static" }, static: false, - kind: "", + kind: "method", value: { type: "FunctionExpression", range: [17, 22], diff --git a/vendor/acorn/test/tests-jsx.js b/vendor/acorn/test/tests-jsx.js new file mode 100644 index 0000000000..68c4af80f9 --- /dev/null +++ b/vendor/acorn/test/tests-jsx.js @@ -0,0 +1,3647 @@ +// React JSX tests + +var fbTestFixture = { + // Taken and adapted from esprima-fb/fbtest.js. + 'JSX': { + '': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "a", + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + selfClosing: true, + attributes: [], + range: [0, 5], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + } + }, + closingElement: null, + children: [], + range: [0, 5], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + } + }, + range: [0, 5], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + } + }, + + '': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXNamespacedName', + namespace: { + type: 'JSXIdentifier', + name: 'n', + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + name: { + type: 'JSXIdentifier', + name: 'a', + range: [3, 4], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + } + }, + range: [1, 4], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 4 } + } + }, + selfClosing: true, + attributes: [{ + type: 'JSXAttribute', + name: { + type: 'JSXNamespacedName', + namespace: { + type: 'JSXIdentifier', + name: 'n', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }, + name: { + type: 'JSXIdentifier', + name: 'v', + range: [7, 8], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + } + }, + range: [5, 8], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 8 } + } + }, + value: null, + range: [5, 8], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 8 } + } + }], + range: [0, 11], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + } + }, + closingElement: null, + children: [], + range: [0, 11], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + } + }, + range: [0, 11], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + } + }, + + ' {value} ': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'a', + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + selfClosing: false, + attributes: [{ + type: 'JSXAttribute', + name: { + type: 'JSXNamespacedName', + namespace: { + type: 'JSXIdentifier', + name: 'n', + range: [3, 4], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + } + }, + name: { + type: 'JSXIdentifier', + name: 'foo', + range: [5, 8], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 8 } + } + }, + range: [3, 8], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + } + }, + value: { + type: 'Literal', + value: 'bar', + raw: '"bar"', + range: [9, 14], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 14 } + } + }, + range: [3, 14], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + } + }], + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXIdentifier', + name: 'a', + range: [38, 39], + loc: { + start: { line: 1, column: 38 }, + end: { line: 1, column: 39 } + } + }, + range: [36, 40], + loc: { + start: { line: 1, column: 36 }, + end: { line: 1, column: 40 } + } + }, + children: [{ + type: 'Literal', + value: ' ', + raw: ' ', + range: [15, 16], + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + } + }, { + type: 'JSXExpressionContainer', + expression: { + type: 'Identifier', + name: 'value', + range: [17, 22], + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 22 } + } + }, + range: [16, 23], + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 23 } + } + }, { + type: 'Literal', + value: ' ', + raw: ' ', + range: [23, 24], + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 24 } + } + }, { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'b', + range: [25, 26], + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + } + }, + selfClosing: false, + attributes: [], + range: [24, 27], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 27 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXIdentifier', + name: 'b', + range: [34, 35], + loc: { + start: { line: 1, column: 34 }, + end: { line: 1, column: 35 } + } + }, + range: [32, 36], + loc: { + start: { line: 1, column: 32 }, + end: { line: 1, column: 36 } + } + }, + children: [{ + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'c', + range: [28, 29], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 29 } + } + }, + selfClosing: true, + attributes: [], + range: [27, 32], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 32 } + } + }, + closingElement: null, + children: [], + range: [27, 32], + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 32 } + } + }], + range: [24, 36], + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 36 } + } + }], + range: [0, 40], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 40 } + } + }, + range: [0, 40], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 40 } + } + }, + + '': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "a", + range: [1, 2] + }, + selfClosing: true, + attributes: [ + { + type: "JSXAttribute", + name: { + type: "JSXIdentifier", + name: "b", + range: [3, 4] + }, + value: { + type: "JSXExpressionContainer", + expression: { + type: "Literal", + value: " ", + raw: "\" \"", + range: [6, 9] + }, + range: [5, 10] + }, + range: [3, 10] + }, + { + type: "JSXAttribute", + name: { + type: "JSXIdentifier", + name: "c", + range: [11, 12] + }, + value: { + type: "Literal", + value: " ", + raw: "\" \"", + range: [13, 16] + }, + range: [11, 16] + }, + { + type: "JSXAttribute", + name: { + type: "JSXIdentifier", + name: "d", + range: [17, 18] + }, + value: { + type: "Literal", + value: "&", + raw: "\"&\"", + range: [19, 26] + }, + range: [17, 26] + }, + { + type: "JSXAttribute", + name: { + type: "JSXIdentifier", + name: "e", + range: [27, 28] + }, + value: { + type: "Literal", + value: "&r;", + raw: "\"&r;\"", + range: [29, 37] + }, + range: [27, 37] + } + ], + range: [0, 40] + }, + closingElement: null, + children: [], + range: [0, 40] + }, + range: [0, 40] + }, + + '': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "a", + range: [ + 1, + 2 + ], + loc: { + start: { + line: 1, + column: 1 + }, + end: { + line: 1, + column: 2 + } + } + }, + selfClosing: true, + attributes: [], + range: [ + 0, + 5 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 2, + column: 2 + } + } + }, + closingElement: null, + children: [], + range: [ + 0, + 5 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 2, + column: 2 + } + } + }, + range: [ + 0, + 5 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 2, + column: 2 + } + } + }, + + '<日本語>': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "日本語", + range: [ + 1, + 4 + ], + loc: { + start: { + line: 1, + column: 1 + }, + end: { + line: 1, + column: 4 + } + } + }, + selfClosing: false, + attributes: [], + range: [ + 0, + 5 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 5 + } + } + }, + closingElement: { + type: "JSXClosingElement", + name: { + type: "JSXIdentifier", + name: "日本語", + range: [ + 7, + 10 + ], + loc: { + start: { + line: 1, + column: 7 + }, + end: { + line: 1, + column: 10 + } + } + }, + range: [ + 5, + 11 + ], + loc: { + start: { + line: 1, + column: 5 + }, + end: { + line: 1, + column: 11 + } + } + }, + children: [], + range: [ + 0, + 11 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 11 + } + } + }, + range: [ + 0, + 11 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 11 + } + } + }, + + '\nbar\nbaz\n': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "AbC-def", + range: [ + 1, + 8 + ], + loc: { + start: { + line: 1, + column: 1 + }, + end: { + line: 1, + column: 8 + } + } + }, + selfClosing: false, + attributes: [ + { + type: "JSXAttribute", + name: { + type: "JSXIdentifier", + name: "test", + range: [ + 11, + 15 + ], + loc: { + start: { + line: 2, + column: 2 + }, + end: { + line: 2, + column: 6 + } + } + }, + value: { + type: "Literal", + value: "&&", + raw: "\"&&\"", + range: [ + 16, + 31 + ], + loc: { + start: { + line: 2, + column: 7 + }, + end: { + line: 2, + column: 22 + } + } + }, + range: [ + 11, + 31 + ], + loc: { + start: { + line: 2, + column: 2 + }, + end: { + line: 2, + column: 22 + } + } + } + ], + range: [ + 0, + 32 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 2, + column: 23 + } + } + }, + closingElement: { + type: "JSXClosingElement", + name: { + type: "JSXIdentifier", + name: "AbC-def", + range: [ + 43, + 50 + ], + loc: { + start: { + line: 5, + column: 2 + }, + end: { + line: 5, + column: 9 + } + } + }, + range: [ + 41, + 51 + ], + loc: { + start: { + line: 5, + column: 0 + }, + end: { + line: 5, + column: 10 + } + } + }, + children: [ + { + type: "Literal", + value: "\nbar\nbaz\n", + raw: "\nbar\nbaz\n", + range: [ + 32, + 41 + ], + loc: { + start: { + line: 2, + column: 23 + }, + end: { + line: 5, + column: 0 + } + } + } + ], + range: [ + 0, + 51 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 5, + column: 10 + } + } + }, + range: [ + 0, + 51 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 5, + column: 10 + } + } + }, + + ' : } />': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "a", + range: [ + 1, + 2 + ], + loc: { + start: { + line: 1, + column: 1 + }, + end: { + line: 1, + column: 2 + } + } + }, + selfClosing: true, + attributes: [ + { + type: "JSXAttribute", + name: { + type: "JSXIdentifier", + name: "b", + range: [ + 3, + 4 + ], + loc: { + start: { + line: 1, + column: 3 + }, + end: { + line: 1, + column: 4 + } + } + }, + value: { + type: "JSXExpressionContainer", + expression: { + type: "ConditionalExpression", + test: { + type: "Identifier", + name: "x", + range: [ + 6, + 7 + ], + loc: { + start: { + line: 1, + column: 6 + }, + end: { + line: 1, + column: 7 + } + } + }, + consequent: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "c", + range: [ + 11, + 12 + ], + loc: { + start: { + line: 1, + column: 11 + }, + end: { + line: 1, + column: 12 + } + } + }, + selfClosing: true, + attributes: [], + range: [ + 10, + 15 + ], + loc: { + start: { + line: 1, + column: 10 + }, + end: { + line: 1, + column: 15 + } + } + }, + closingElement: null, + children: [], + range: [ + 10, + 15 + ], + loc: { + start: { + line: 1, + column: 10 + }, + end: { + line: 1, + column: 15 + } + } + }, + alternate: { + type: "JSXElement", + openingElement: { + type: "JSXOpeningElement", + name: { + type: "JSXIdentifier", + name: "d", + range: [ + 19, + 20 + ], + loc: { + start: { + line: 1, + column: 19 + }, + end: { + line: 1, + column: 20 + } + } + }, + selfClosing: true, + attributes: [], + range: [ + 18, + 23 + ], + loc: { + start: { + line: 1, + column: 18 + }, + end: { + line: 1, + column: 23 + } + } + }, + closingElement: null, + children: [], + range: [ + 18, + 23 + ], + loc: { + start: { + line: 1, + column: 18 + }, + end: { + line: 1, + column: 23 + } + } + }, + range: [ + 6, + 23 + ], + loc: { + start: { + line: 1, + column: 6 + }, + end: { + line: 1, + column: 23 + } + } + }, + range: [ + 5, + 24 + ], + loc: { + start: { + line: 1, + column: 5 + }, + end: { + line: 1, + column: 24 + } + } + }, + range: [ + 3, + 24 + ], + loc: { + start: { + line: 1, + column: 3 + }, + end: { + line: 1, + column: 24 + } + } + } + ], + range: [ + 0, + 27 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 27 + } + } + }, + closingElement: null, + children: [], + range: [ + 0, + 27 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 27 + } + } + }, + range: [ + 0, + 27 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 27 + } + } + }, + + '{}': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'a', + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + selfClosing: false, + attributes: [], + range: [0, 3], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 3 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXIdentifier', + name: 'a', + range: [7, 8], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + } + }, + range: [5, 9], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 9 } + } + }, + children: [{ + type: 'JSXExpressionContainer', + expression: { + type: 'JSXEmptyExpression', + range: [4, 4], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 4 } + } + }, + range: [3, 5], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 5 } + } + }], + range: [0, 9], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 9 } + } + }, + range: [0, 9], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 9 } + } + }, + + '{/* this is a comment */}': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'a', + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + selfClosing: false, + attributes: [], + range: [0, 3], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 3 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXIdentifier', + name: 'a', + range: [30, 31], + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 31 } + } + }, + range: [28, 32], + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 32 } + } + }, + children: [{ + type: 'JSXExpressionContainer', + expression: { + type: 'JSXEmptyExpression', + range: [4, 27], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 27 } + } + }, + range: [3, 28], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 28 } + } + }], + range: [0, 32], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 32 } + } + }, + range: [0, 32], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 32 } + } + }, + + '
@test content
': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'div', + range: [1, 4], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 4 } + } + }, + selfClosing: false, + attributes: [], + range: [0, 5], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXIdentifier', + name: 'div', + range: [20, 23], + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + } + }, + range: [18, 24], + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 24 } + } + }, + children: [{ + type: 'Literal', + value: '@test content', + raw: '@test content', + range: [5, 18], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 18 } + } + }], + range: [0, 24], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 24 } + } + }, + range: [0, 24], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 24 } + } + }, + + '

7x invalid-js-identifier
': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'div', + range: [ + 1, + 4 + ], + loc: { + start: { + line: 1, + column: 1 + }, + end: { + line: 1, + column: 4 + } + } + }, + selfClosing: false, + attributes: [], + range: [ + 0, + 5 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 5 + } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXIdentifier', + name: 'div', + range: [ + 37, + 40 + ], + loc: { + start: { + line: 1, + column: 37 + }, + end: { + line: 1, + column: 40 + } + } + }, + range: [ + 35, + 41 + ], + loc: { + start: { + line: 1, + column: 35 + }, + end: { + line: 1, + column: 41 + } + } + }, + children: [{ + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'br', + range: [ + 6, + 8 + ], + loc: { + start: { + line: 1, + column: 6 + }, + end: { + line: 1, + column: 8 + } + } + }, + selfClosing: true, + attributes: [], + range: [ + 5, + 11 + ], + loc: { + start: { + line: 1, + column: 5 + }, + end: { + line: 1, + column: 11 + } + } + }, + closingElement: null, + children: [], + range: [ + 5, + 11 + ], + loc: { + start: { + line: 1, + column: 5 + }, + end: { + line: 1, + column: 11 + } + } + }, { + type: 'Literal', + value: '7x invalid-js-identifier', + raw: '7x invalid-js-identifier', + range: [ + 11, + 35 + ], + loc: { + start: { + line: 1, + column: 11 + }, + end: { + line: 1, + column: 35 + } + } + }], + range: [ + 0, + 41 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 41 + } + } + }, + range: [ + 0, + 41 + ], + loc: { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 41 + } + } + }, + + ' right=monkeys /> gorillas />': { + "type": "ExpressionStatement", + "expression": { + "type": "JSXElement", + "openingElement": { + "type": "JSXOpeningElement", + "name": { + "type": "JSXIdentifier", + "name": "LeftRight", + "range": [ + 1, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "JSXAttribute", + "name": { + "type": "JSXIdentifier", + "name": "left", + "range": [ + 11, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + } + } + }, + "value": { + "type": "JSXElement", + "openingElement": { + "type": "JSXOpeningElement", + "name": { + "type": "JSXIdentifier", + "name": "a", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + "selfClosing": true, + "attributes": [], + "range": [ + 16, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + closingElement: null, + "children": [], + "range": [ + 16, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + "range": [ + 11, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + { + "type": "JSXAttribute", + "name": { + "type": "JSXIdentifier", + "name": "right", + "range": [ + 22, + 27 + ], + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + "value": { + "type": "JSXElement", + "openingElement": { + "type": "JSXOpeningElement", + "name": { + "type": "JSXIdentifier", + "name": "b", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + "selfClosing": false, + "attributes": [], + "range": [ + 28, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "closingElement": { + "type": "JSXClosingElement", + "name": { + "type": "JSXIdentifier", + "name": "b", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 53 + } + } + }, + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 54 + } + } + }, + "children": [ + { + "type": "Literal", + "value": "monkeys /> gorillas", + "raw": "monkeys /> gorillas", + "range": [ + 31, + 50 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 50 + } + } + } + ], + "range": [ + 28, + 54 + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 54 + } + } + }, + "range": [ + 22, + 54 + ], + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 54 + } + } + } + ], + "range": [ + 0, + 57 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + } + }, + closingElement: null, + "children": [], + "range": [ + 0, + 57 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + } + }, + "range": [ + 0, + 57 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + } + }, + + '': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXMemberExpression', + object: { + type: 'JSXIdentifier', + name: 'a', + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + property: { + type: 'JSXIdentifier', + name: 'b', + range: [3, 4], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + } + }, + range: [1, 4], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 4 } + } + }, + selfClosing: false, + attributes: [], + range: [0, 5], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXMemberExpression', + object: { + type: 'JSXIdentifier', + name: 'a', + range: [7, 8], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + } + }, + property: { + type: 'JSXIdentifier', + name: 'b', + range: [9, 10], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 10 } + } + }, + range: [7, 10], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 10 } + } + }, + range: [5, 11], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 11 } + } + }, + children: [], + range: [0, 11], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + } + }, + range: [0, 11], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + } + }, + + '': { + type: 'ExpressionStatement', + expression: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXMemberExpression', + object: { + type: 'JSXMemberExpression', + object: { + type: 'JSXIdentifier', + name: 'a', + range: [1, 2], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 2 } + } + }, + property: { + type: 'JSXIdentifier', + name: 'b', + range: [3, 4], + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + } + }, + range: [1, 4], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 4 } + } + }, + property: { + type: 'JSXIdentifier', + name: 'c', + range: [5, 6], + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + } + }, + range: [1, 6], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 6 } + } + }, + selfClosing: false, + attributes: [], + range: [0, 7], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 7 } + } + }, + closingElement: { + type: 'JSXClosingElement', + name: { + type: 'JSXMemberExpression', + object: { + type: 'JSXMemberExpression', + object: { + type: 'JSXIdentifier', + name: 'a', + range: [9, 10], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 10 } + } + }, + property: { + type: 'JSXIdentifier', + name: 'b', + range: [11, 12], + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 12 } + } + }, + range: [9, 12], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 12 } + } + }, + property: { + type: 'JSXIdentifier', + name: 'c', + range: [13, 14], + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + } + }, + range: [9, 14], + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 14 } + } + }, + range: [7, 15], + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 15 } + } + }, + children: [], + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + range: [0, 15], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 15 } + } + }, + + // In order to more useful parse errors, we disallow following an + // JSXElement by a less-than symbol. In the rare case that the binary + // operator was intended, the tag can be wrapped in parentheses: + '(
) < x;': { + type: 'ExpressionStatement', + expression: { + type: 'BinaryExpression', + operator: '<', + left: { + type: 'JSXElement', + openingElement: { + type: 'JSXOpeningElement', + name: { + type: 'JSXIdentifier', + name: 'div', + range: [2, 5], + loc: { + start: { line: 1, column: 2 }, + end: { line: 1, column: 5 } + } + }, + selfClosing: true, + attributes: [], + range: [1, 8], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 8 } + } + }, + closingElement: null, + children: [], + range: [1, 8], + loc: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 8 } + } + }, + right: { + type: 'Identifier', + name: 'x', + range: [12, 13], + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 13 } + } + }, + range: [0, 13], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 13 } + } + }, + range: [0, 14], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 14 } + } + }, + + '
': { + "type": "ExpressionStatement", + "expression": { + "type": "JSXElement", + "openingElement": { + "type": "JSXOpeningElement", + "name": { + "type": "JSXIdentifier", + "name": "div", + "range": [ + 1, + 4 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "JSXSpreadAttribute", + "argument": { + "type": "Identifier", + "name": "props", + "range": [ + 9, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + "range": [ + 5, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + ], + "range": [ + 0, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + closingElement: null, + "children": [], + "range": [ + 0, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + "range": [ + 0, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + + '
': { + "type": "ExpressionStatement", + "expression": { + "type": "JSXElement", + "openingElement": { + "type": "JSXOpeningElement", + "name": { + "type": "JSXIdentifier", + "name": "div", + "range": [ + 1, + 4 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "JSXSpreadAttribute", + "argument": { + "type": "Identifier", + "name": "props", + "range": [ + 9, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + "range": [ + 5, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + } + }, + { + "type": "JSXAttribute", + "name": { + "type": "JSXIdentifier", + "name": "post", + "range": [ + 16, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + "value": { + "type": "Literal", + "value": "attribute", + "raw": "\"attribute\"", + "range": [ + 21, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 32 + } + } + }, + "range": [ + 16, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 32 + } + } + } + ], + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + closingElement: null, + "children": [], + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + + '
': { + "type": "ExpressionStatement", + "expression": { + "type": "JSXElement", + "openingElement": { + "type": "JSXOpeningElement", + "name": { + "type": "JSXIdentifier", + "name": "div", + "range": [ + 1, + 4 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "JSXAttribute", + "name": { + "type": "JSXIdentifier", + "name": "pre", + "range": [ + 5, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + "value": { + "type": "Literal", + "value": "leading", + "raw": "\"leading\"", + "range": [ + 9, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + "range": [ + 5, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "JSXAttribute", + "name": { + "type": "JSXIdentifier", + "name": "pre2", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + } + }, + "value": { + "type": "Literal", + "value": "attribute", + "raw": "\"attribute\"", + "range": [ + 24, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "range": [ + 19, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + { + "type": "JSXSpreadAttribute", + "argument": { + "type": "Identifier", + "name": "props", + "range": [ + 40, + 45 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 45 + } + } + }, + "range": [ + 36, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + ], + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + } + }, + "closingElement": { + "type": "JSXClosingElement", + "name": { + "type": "JSXIdentifier", + "name": "div", + "range": [ + 49, + 52 + ], + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 52 + } + } + }, + "range": [ + 47, + 53 + ], + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 53 + } + } + }, + "children": [], + "range": [ + 0, + 53 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + } + }, + "range": [ + 0, + 53 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + } + }, + + '
{aa.b}
': { + "type": "ExpressionStatement", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "range": [ + 0, + 52 + ], + "expression": { + "type": "JSXElement", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "range": [ + 0, + 52 + ], + "openingElement": { + "type": "JSXOpeningElement", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 0, + 31 + ], + "attributes": [ + { + "type": "JSXAttribute", + "start": 3, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 3, + 16 + ], + "name": { + "type": "JSXIdentifier", + "start": 3, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 3, + 5 + ], + "name": "aa" + }, + "value": { + "type": "JSXExpressionContainer", + "start": 6, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 6, + 16 + ], + "expression": { + "type": "MemberExpression", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 7, + 15 + ], + "object": { + "type": "MemberExpression", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 7, + 12 + ], + "object": { + "type": "Identifier", + "start": 7, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 7, + 9 + ], + "name": "aa" + }, + "property": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 10, + 12 + ], + "name": "bb" + }, + "computed": false + }, + "property": { + "type": "Identifier", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 13, + 15 + ], + "name": "cc" + }, + "computed": false + } + } + }, + { + "type": "JSXAttribute", + "start": 17, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 17, + 30 + ], + "name": { + "type": "JSXIdentifier", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 17, + 19 + ], + "name": "bb" + }, + "value": { + "type": "JSXExpressionContainer", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 20, + 30 + ], + "expression": { + "type": "MemberExpression", + "start": 21, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 21, + 29 + ], + "object": { + "type": "MemberExpression", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 21, + 26 + ], + "object": { + "type": "Identifier", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 21, + 23 + ], + "name": "bb" + }, + "property": { + "type": "Identifier", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 24, + 26 + ], + "name": "cc" + }, + "computed": false + }, + "property": { + "type": "Identifier", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 27, + 29 + ], + "name": "dd" + }, + "computed": false + } + } + } + ], + "name": { + "type": "JSXIdentifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ], + "name": "A" + }, + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "range": [ + 48, + 52 + ], + "name": { + "type": "JSXIdentifier", + "start": 50, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "range": [ + 50, + 51 + ], + "name": "A" + } + }, + "children": [ + { + "type": "JSXElement", + "start": 31, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "range": [ + 31, + 48 + ], + "openingElement": { + "type": "JSXOpeningElement", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 31, + 36 + ], + "attributes": [], + "name": { + "type": "JSXIdentifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 32, + 35 + ], + "name": "div" + }, + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", + "start": 42, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "range": [ + 42, + 48 + ], + "name": { + "type": "JSXIdentifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 44, + 47 + ], + "name": "div" + } + }, + "children": [ + { + "type": "JSXExpressionContainer", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 36, + 42 + ], + "expression": { + "type": "MemberExpression", + "start": 37, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 37, + 41 + ], + "object": { + "type": "Identifier", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 37, + 39 + ], + "name": "aa" + }, + "property": { + "type": "Identifier", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 40, + 41 + ], + "name": "b" + }, + "computed": false + } + } + ] + } + ] + } + } + }, + 'Regression': { + '

foo bar baz

;': { + type: "ExpressionStatement", + start: 0, + end: 40, + expression: { + type: "JSXElement", + start: 0, + end: 38, + openingElement: { + type: "JSXOpeningElement", + start: 0, + end: 3, + attributes: [], + name: { + type: "JSXIdentifier", + start: 1, + end: 2, + name: "p" + }, + selfClosing: false + }, + closingElement: { + type: "JSXClosingElement", + start: 34, + end: 38, + name: { + type: "JSXIdentifier", + start: 36, + end: 37, + name: "p" + } + }, + children: [ + { + type: "Literal", + start: 3, + end: 7, + value: "foo ", + raw: "foo " + }, + { + type: "JSXElement", + start: 7, + end: 30, + openingElement: { + type: "JSXOpeningElement", + start: 7, + end: 22, + attributes: [{ + type: "JSXAttribute", + start: 10, + end: 21, + name: { + type: "JSXIdentifier", + start: 10, + end: 14, + name: "href" + }, + value: { + type: "Literal", + start: 15, + end: 21, + value: "test", + raw: "\"test\"" + } + }], + name: { + type: "JSXIdentifier", + start: 8, + end: 9, + name: "a" + }, + selfClosing: false + }, + closingElement: { + type: "JSXClosingElement", + start: 26, + end: 30, + name: { + type: "JSXIdentifier", + start: 28, + end: 29, + name: "a" + } + }, + children: [{ + type: "Literal", + start: 22, + end: 26, + value: " bar", + raw: " bar" + }] + }, + { + type: "Literal", + start: 30, + end: 34, + value: " baz", + raw: " baz" + } + ] + } + }, + + '
{
}
': { + type: 'ExpressionStatement', + start: 0, + end: 30, + expression: { + type: 'JSXElement', + start: 0, + end: 30, + openingElement: { + type: 'JSXOpeningElement', + start: 0, + end: 5, + attributes: [], + name: { + type: 'JSXIdentifier', + start: 1, + end: 4, + name: 'div' + }, + selfClosing: false + }, + closingElement: { + type: 'JSXClosingElement', + start: 24, + end: 30, + name: { + type: 'JSXIdentifier', + start: 26, + end: 29, + name: 'div' + } + }, + children: [{ + type: 'JSXExpressionContainer', + start: 5, + end: 24, + expression: { + type: 'JSXElement', + start: 6, + end: 23, + openingElement: { + type: 'JSXOpeningElement', + start: 6, + end: 23, + attributes: [ + { + type: 'JSXSpreadAttribute', + start: 11, + end: 20, + argument: { + type: 'Identifier', + start: 15, + end: 19, + name: 'test' + } + } + ], + name: { + type: 'JSXIdentifier', + start: 7, + end: 10, + name: 'div' + }, + selfClosing: true + }, + closingElement: null, + children: [] + } + }] + } + }, + + '
{ {a} }
': { + type: "ExpressionStatement", + start: 0, + end: 18, + expression: { + type: "JSXElement", + start: 0, + end: 18, + openingElement: { + type: "JSXOpeningElement", + start: 0, + end: 5, + attributes: [], + name: { + type: "JSXIdentifier", + start: 1, + end: 4, + name: "div" + }, + selfClosing: false + }, + closingElement: { + type: "JSXClosingElement", + start: 12, + end: 18, + name: { + type: "JSXIdentifier", + start: 14, + end: 17, + name: "div" + } + }, + children: [{ + type: "JSXExpressionContainer", + start: 5, + end: 12, + expression: { + type: "ObjectExpression", + start: 7, + end: 10, + properties: [{ + type: "Property", + start: 8, + end: 9, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 8, + end: 9, + name: "a" + }, + kind: "init", + value: { + type: "Identifier", + start: 8, + end: 9, + name: "a" + } + }] + } + }] + } + }, + + '
/text
': { + type: "ExpressionStatement", + start: 0, + end: 16, + expression: { + type: "JSXElement", + start: 0, + end: 16, + openingElement: { + type: "JSXOpeningElement", + start: 0, + end: 5, + attributes: [], + name: { + type: "JSXIdentifier", + start: 1, + end: 4, + name: "div" + }, + selfClosing: false + }, + closingElement: { + type: "JSXClosingElement", + start: 10, + end: 16, + name: { + type: "JSXIdentifier", + start: 12, + end: 15, + name: "div" + } + }, + children: [{ + type: "Literal", + start: 5, + end: 10, + value: "/text", + raw: "/text" + }] + } + }, + + '
{a}{b}
': { + type: "ExpressionStatement", + start: 0, + end: 17, + expression: { + type: "JSXElement", + start: 0, + end: 17, + openingElement: { + type: "JSXOpeningElement", + start: 0, + end: 5, + attributes: [], + name: { + type: "JSXIdentifier", + start: 1, + end: 4, + name: "div" + }, + selfClosing: false + }, + closingElement: { + type: "JSXClosingElement", + start: 11, + end: 17, + name: { + type: "JSXIdentifier", + start: 13, + end: 16, + name: "div" + } + }, + children: [{ + type: 'JSXExpressionContainer', + expression: { + type: 'Identifier', + name: 'a', + range: [6, 7], + loc: { + start: { + line: 1, + column: 6 + }, + end: { + line: 1, + column: 7 + } + } + }, + range: [5, 8], + loc: { + start: { + line: 1, + column: 5 + }, + end: { + line: 1, + column: 8 + } + } + }, { + type: 'JSXExpressionContainer', + expression: { + type: 'Identifier', + name: 'b', + range: [9, 10], + loc: { + start: { + line: 1, + column: 9 + }, + end: { + line: 1, + column: 10 + } + } + }, + range: [8, 11], + loc: { + start: { + line: 1, + column: 8 + }, + end: { + line: 1, + column: 11 + } + } + } + ] + } + }, + + '
': { + type: "ExpressionStatement", + range: [0, 32], + expression: { + type: "JSXElement", + range: [0, 32], + openingElement: { + type: "JSXOpeningElement", + range: [0, 32], + attributes: [ + { + type: "JSXAttribute", + range: [5, 18], + name: { + type: "JSXIdentifier", + range: [5, 8], + name: "pre" + }, + value: { + type: "Literal", + range: [9, 18], + value: "leading" + } + }, + { + type: "JSXSpreadAttribute", + range: [19, 29], + argument: { + type: "Identifier", + range: [23, 28], + name: "props" + } + } + ], + name: { + type: "JSXIdentifier", + range: [1, 4], + name: "div" + }, + selfClosing: true + }, + closingElement: null, + children: [] + } + }, + '': { + type: "ExpressionStatement", + expression: { + type: "JSXElement", + range: [0, 64], + openingElement: { + type: "JSXOpeningElement", + range: [0, 64], + attributes: [ + { + type: "JSXAttribute", + range: [6, 62], + name: { + type: "JSXIdentifier", + range: [6, 7], + name: "d" + }, + value: { + type: "Literal", + range: [8, 62], + value: "M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z", + raw: "\"M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z\"" + } + } + ], + name: { + type: "JSXIdentifier", + range: [1, 5], + name: "path" + }, + selfClosing: true + }, + closingElement: null, + children: [] + } + } + } +}; + +if (typeof exports !== "undefined") { + var test = require("./driver.js").test; +} + +for (var ns in fbTestFixture) { + ns = fbTestFixture[ns]; + for (var code in ns) { + test(code, { + type: 'Program', + body: [ns[code]] + }, { + ecmaVersion: 6, + plugins: { jsx: true }, + locations: true, + ranges: true + }); + } +} diff --git a/lib/acorn/test/tests.js b/vendor/acorn/test/tests.js similarity index 100% rename from lib/acorn/test/tests.js rename to vendor/acorn/test/tests.js diff --git a/lib/acorn/tools/generate-identifier-regex.js b/vendor/acorn/tools/generate-identifier-regex.js similarity index 100% rename from lib/acorn/tools/generate-identifier-regex.js rename to vendor/acorn/tools/generate-identifier-regex.js