diff --git a/src/plugins/flow.js b/src/plugins/flow.js index e86b8455c4..6c22a44ae3 100644 --- a/src/plugins/flow.js +++ b/src/plugins/flow.js @@ -275,8 +275,13 @@ pp.flowParseObjectTypeIndexer = function (node, isStatic, variance) { node.static = isStatic; this.expect(tt.bracketL); - node.id = this.flowParseObjectPropertyKey(); - node.key = this.flowParseTypeInitialiser(); + if (this.lookahead().type === tt.colon) { + node.id = this.flowParseObjectPropertyKey(); + node.key = this.flowParseTypeInitialiser(); + } else { + node.id = null; + node.key = this.flowParseType(); + } this.expect(tt.bracketR); node.value = this.flowParseTypeInitialiser(); node.variance = variance; @@ -466,19 +471,37 @@ pp.flowParseTupleType = function () { }; pp.flowParseFunctionTypeParam = function () { + let name = null; let optional = false; + let typeAnnotation = null; let node = this.startNode(); - node.name = this.parseIdentifier(); - if (this.eat(tt.question)) { - optional = true; + const lh = this.lookahead(); + if (lh.type === tt.colon || + lh.type === tt.question) { + name = this.parseIdentifier(); + if (this.eat(tt.question)) { + optional = true; + } + typeAnnotation = this.flowParseTypeInitialiser(); + } else { + typeAnnotation = this.flowParseType(); } + node.name = name; node.optional = optional; - node.typeAnnotation = this.flowParseTypeInitialiser(); + node.typeAnnotation = typeAnnotation; return this.finishNode(node, "FunctionTypeParam"); }; -pp.flowParseFunctionTypeParams = function () { - let ret = { params: [], rest: null }; +pp.reinterpretTypeAsFunctionTypeParam = function (type) { + let node = this.startNodeAt(type.start, type.loc); + node.name = null; + node.optional = false; + node.typeAnnotation = type; + return this.finishNode(node, "FunctionTypeParam"); +}; + +pp.flowParseFunctionTypeParams = function (params = []) { + let ret = { params, rest: null }; while (this.match(tt.name)) { ret.params.push(this.flowParseFunctionTypeParam()); if (!this.match(tt.parenR)) { @@ -529,6 +552,7 @@ pp.flowParsePrimaryType = function () { let tmp; let type; let isGroupedType = false; + let oldNoAnonFunctionType = this.state.noAnonFunctionType; switch (this.state.type) { case tt.name: @@ -574,12 +598,30 @@ pp.flowParsePrimaryType = function () { } if (isGroupedType) { + this.state.noAnonFunctionType = false; type = this.flowParseType(); - this.expect(tt.parenR); - return type; + this.state.noAnonFunctionType = oldNoAnonFunctionType; + + // A `,` or a `) =>` means this is an anonymous function type + if (this.state.noAnonFunctionType || + !(this.match(tt.comma) || + (this.match(tt.parenR) && this.lookahead().type === tt.arrow))) { + this.expect(tt.parenR); + return type; + } else { + // Eat a comma if there is one + this.eat(tt.comma); + } + } + + if (type) { + tmp = this.flowParseFunctionTypeParams( + [this.reinterpretTypeAsFunctionTypeParam(type)], + ); + } else { + tmp = this.flowParseFunctionTypeParams(); } - tmp = this.flowParseFunctionTypeParams(); node.params = tmp.params; node.rest = tmp.rest; @@ -588,6 +630,7 @@ pp.flowParsePrimaryType = function () { this.expect(tt.arrow); node.returnType = this.flowParseType(); + node.typeParameters = null; return this.finishNode(node, "FunctionTypeAnnotation"); @@ -668,12 +711,25 @@ pp.flowParsePrefixType = function () { } }; +pp.flowParseAnonFunctionWithoutParens = function () { + const param = this.flowParsePrefixType(); + if (!this.state.noAnonFunctionType && this.eat(tt.arrow)) { + const node = this.startNodeAt(param.start, param.loc); + node.params = [this.reinterpretTypeAsFunctionTypeParam(param)]; + node.rest = null; + node.returnType = this.flowParseType(); + node.typeParameters = null; + return this.finishNode(node, "FunctionTypeAnnotation"); + } + return param; +}; + pp.flowParseIntersectionType = function () { let node = this.startNode(); - let type = this.flowParsePrefixType(); + let type = this.flowParseAnonFunctionWithoutParens(); node.types = [type]; while (this.eat(tt.bitwiseAND)) { - node.types.push(this.flowParsePrefixType()); + node.types.push(this.flowParseAnonFunctionWithoutParens()); } return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation"); }; @@ -1156,7 +1212,10 @@ export default function (instance) { instance.extend("parseAsyncArrowFromCallExpression", function (inner) { return function (node, call) { if (this.match(tt.colon)) { + const oldNoAnonFunctionType = this.state.noAnonFunctionType; + this.state.noAnonFunctionType = true; node.returnType = this.flowParseTypeAnnotation(); + this.state.noAnonFunctionType = oldNoAnonFunctionType; } return inner.call(this, node, call); @@ -1238,7 +1297,11 @@ export default function (instance) { if (this.match(tt.colon)) { let state = this.state.clone(); try { + const oldNoAnonFunctionType = this.state.noAnonFunctionType; + this.state.noAnonFunctionType = true; let returnType = this.flowParseTypeAnnotation(); + this.state.noAnonFunctionType = oldNoAnonFunctionType; + if (this.canInsertSemicolon()) this.unexpected(); if (!this.match(tt.arrow)) this.unexpected(); // assign after it is clear it is an arrow diff --git a/src/tokenizer/state.js b/src/tokenizer/state.js index 2b0f57c847..1436eb9fee 100644 --- a/src/tokenizer/state.js +++ b/src/tokenizer/state.js @@ -12,7 +12,13 @@ export default class State { this.potentialArrowAt = -1; - this.inMethod = this.inFunction = this.inGenerator = this.inAsync = this.inType = false; + this.inMethod = + this.inFunction = + this.inGenerator = + this.inAsync = + this.inType = + this.noAnonFunctionType = + false; this.labels = []; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/bad_01/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/bad_01/actual.js new file mode 100644 index 0000000000..a5c4b28a36 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/bad_01/actual.js @@ -0,0 +1 @@ +var f = (x): number => 123 => 123; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/bad_01/options.json b/test/fixtures/flow/anonymous-function-no-parens-types/bad_01/options.json new file mode 100644 index 0000000000..2f68c0372c --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/bad_01/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ; (1:27)" +} diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/bad_02/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/bad_02/actual.js new file mode 100644 index 0000000000..c8785fdd50 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/bad_02/actual.js @@ -0,0 +1 @@ +var f = (x): string | number => 123 => 123; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/bad_02/options.json b/test/fixtures/flow/anonymous-function-no-parens-types/bad_02/options.json new file mode 100644 index 0000000000..52a8725a65 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/bad_02/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ; (1:36)" +} diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_01/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_01/actual.js new file mode 100644 index 0000000000..8c0af33050 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_01/actual.js @@ -0,0 +1 @@ +type A = string => void diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_01/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_01/expected.json new file mode 100644 index 0000000000..a316747821 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_01/expected.json @@ -0,0 +1,145 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 23, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "end": { + "line": 1, + "column": 23 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 9, + "end": 18, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 19, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_02/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_02/actual.js new file mode 100644 index 0000000000..c8d9391370 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_02/actual.js @@ -0,0 +1 @@ +type A = Array => void diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_02/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_02/expected.json new file mode 100644 index 0000000000..b471f333b9 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_02/expected.json @@ -0,0 +1,194 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 30, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "end": { + "line": 1, + "column": 30 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 9, + "end": 25, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "end": { + "line": 1, + "column": 25 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "params": [ + { + "type": "StringTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "Array" + }, + "name": "Array" + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 26, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_03/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_03/actual.js new file mode 100644 index 0000000000..cde006a11c --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_03/actual.js @@ -0,0 +1 @@ +var f = (): number => 123; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_03/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_03/expected.json new file mode 100644 index 0000000000..a09644e718 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_03/expected.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 10, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [], + "body": { + "type": "NumericLiteral", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_04/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_04/actual.js new file mode 100644 index 0000000000..f2cd97d81c --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_04/actual.js @@ -0,0 +1 @@ +var f = (): string | number => 123; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_04/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_04/expected.json new file mode 100644 index 0000000000..7383572fa8 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_04/expected.json @@ -0,0 +1,186 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 10, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "typeAnnotation": { + "type": "UnionTypeAnnotation", + "start": 12, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "types": [ + { + "type": "StringTypeAnnotation", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + } + } + ] + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [], + "body": { + "type": "NumericLiteral", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_05/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_05/actual.js new file mode 100644 index 0000000000..6745818419 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_05/actual.js @@ -0,0 +1 @@ +var f = (x): (number => 123) => 123; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_05/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_05/expected.json new file mode 100644 index 0000000000..073bb795bf --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_05/expected.json @@ -0,0 +1,240 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 11, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 14, + "end": 27, + "loc": { + "start": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 14, + "end": 23, + "loc": { + "start": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "NumericLiteralTypeAnnotation", + "start": 24, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": 123, + "extra": { + "rawValue": 123, + "raw": "123" + } + }, + "typeParameters": null + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "NumericLiteral", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_06/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_06/actual.js new file mode 100644 index 0000000000..27fee5a424 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_06/actual.js @@ -0,0 +1 @@ +type A = string | number => boolean; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_06/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_06/expected.json new file mode 100644 index 0000000000..ba1a77003d --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_06/expected.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "UnionTypeAnnotation", + "start": 9, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "types": [ + { + "type": "StringTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + }, + { + "type": "FunctionTypeAnnotation", + "start": 18, + "end": 35, + "loc": { + "start": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "end": { + "line": 1, + "column": 35 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 18, + "end": 27, + "loc": { + "start": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 18, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "BooleanTypeAnnotation", + "start": 28, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "typeParameters": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_07/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_07/actual.js new file mode 100644 index 0000000000..6804ca3288 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_07/actual.js @@ -0,0 +1 @@ +type A = string & number => boolean; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_07/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_07/expected.json new file mode 100644 index 0000000000..8b6a000ca8 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_07/expected.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "IntersectionTypeAnnotation", + "start": 9, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "types": [ + { + "type": "StringTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + }, + { + "type": "FunctionTypeAnnotation", + "start": 18, + "end": 35, + "loc": { + "start": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "end": { + "line": 1, + "column": 35 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 18, + "end": 27, + "loc": { + "start": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 18, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "BooleanTypeAnnotation", + "start": 28, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "typeParameters": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_08/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_08/actual.js new file mode 100644 index 0000000000..e558d0d497 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_08/actual.js @@ -0,0 +1 @@ +type A = ?number => boolean; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_08/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_08/expected.json new file mode 100644 index 0000000000..f0550ddb38 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_08/expected.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 27, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 9, + "end": 19, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 19 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "NullableTypeAnnotation", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "BooleanTypeAnnotation", + "start": 20, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_09/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_09/actual.js new file mode 100644 index 0000000000..201f439c87 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_09/actual.js @@ -0,0 +1 @@ +type A = number[] => boolean; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_09/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_09/expected.json new file mode 100644 index 0000000000..139ec5c439 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_09/expected.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 28, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "end": { + "line": 1, + "column": 28 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 9, + "end": 20, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "end": { + "line": 1, + "column": 20 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "ArrayTypeAnnotation", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "elementType": { + "type": "NumberTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "BooleanTypeAnnotation", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 28 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_10/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_10/actual.js new file mode 100644 index 0000000000..c2bbde7454 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_10/actual.js @@ -0,0 +1 @@ +type A = (string => boolean) => number diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_10/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_10/expected.json new file mode 100644 index 0000000000..e8d0032620 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_10/expected.json @@ -0,0 +1,208 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 27, + "loc": { + "start": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 10, + "end": 27, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 27 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 19, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 19 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "BooleanTypeAnnotation", + "start": 20, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + "typeParameters": null + } + } + ], + "rest": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_11/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_11/actual.js new file mode 100644 index 0000000000..40667e638b --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_11/actual.js @@ -0,0 +1 @@ +type A = string => boolean | number; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_11/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_11/expected.json new file mode 100644 index 0000000000..bb69ccf823 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_11/expected.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 35, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "end": { + "line": 1, + "column": 35 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 9, + "end": 18, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "UnionTypeAnnotation", + "start": 19, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "types": [ + { + "type": "BooleanTypeAnnotation", + "start": 19, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + { + "type": "NumberTypeAnnotation", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 35 + } + } + } + ] + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_12/actual.js b/test/fixtures/flow/anonymous-function-no-parens-types/good_12/actual.js new file mode 100644 index 0000000000..619a5f6267 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_12/actual.js @@ -0,0 +1 @@ +type A = string => boolean => number; diff --git a/test/fixtures/flow/anonymous-function-no-parens-types/good_12/expected.json b/test/fixtures/flow/anonymous-function-no-parens-types/good_12/expected.json new file mode 100644 index 0000000000..e4fbe0fafa --- /dev/null +++ b/test/fixtures/flow/anonymous-function-no-parens-types/good_12/expected.json @@ -0,0 +1,208 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 36, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "end": { + "line": 1, + "column": 36 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 9, + "end": 18, + "loc": { + "start": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "FunctionTypeAnnotation", + "start": 19, + "end": 36, + "loc": { + "start": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "end": { + "line": 1, + "column": 36 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 19, + "end": 29, + "loc": { + "start": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "end": { + "line": 1, + "column": 29 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "BooleanTypeAnnotation", + "start": 19, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 30, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 36 + } + } + }, + "typeParameters": null + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/bad_01/actual.js b/test/fixtures/flow/anonymous-function-types/bad_01/actual.js new file mode 100644 index 0000000000..198603ae43 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/bad_01/actual.js @@ -0,0 +1 @@ +var f = (x): (number) => 123 => 123; diff --git a/test/fixtures/flow/anonymous-function-types/bad_01/options.json b/test/fixtures/flow/anonymous-function-types/bad_01/options.json new file mode 100644 index 0000000000..7dcae78ae3 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/bad_01/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ; (1:29)" +} diff --git a/test/fixtures/flow/anonymous-function-types/bad_02/actual.js b/test/fixtures/flow/anonymous-function-types/bad_02/actual.js new file mode 100644 index 0000000000..f3763dc952 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/bad_02/actual.js @@ -0,0 +1 @@ +var f = (x): string | (number) => 123 => 123; diff --git a/test/fixtures/flow/anonymous-function-types/bad_02/options.json b/test/fixtures/flow/anonymous-function-types/bad_02/options.json new file mode 100644 index 0000000000..1e8c905871 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/bad_02/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ; (1:38)" +} diff --git a/test/fixtures/flow/anonymous-function-types/bad_03/actual.js b/test/fixtures/flow/anonymous-function-types/bad_03/actual.js new file mode 100644 index 0000000000..74eb1fdbdf --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/bad_03/actual.js @@ -0,0 +1 @@ +var f = (x): ?(number) => 123 => 123; diff --git a/test/fixtures/flow/anonymous-function-types/bad_03/options.json b/test/fixtures/flow/anonymous-function-types/bad_03/options.json new file mode 100644 index 0000000000..62e1e03ac5 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/bad_03/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ; (1:30)" +} diff --git a/test/fixtures/flow/anonymous-function-types/good_01/actual.js b/test/fixtures/flow/anonymous-function-types/good_01/actual.js new file mode 100644 index 0000000000..172029374b --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_01/actual.js @@ -0,0 +1 @@ +declare function foo(x: number, string): void; diff --git a/test/fixtures/flow/anonymous-function-types/good_01/expected.json b/test/fixtures/flow/anonymous-function-types/good_01/expected.json new file mode 100644 index 0000000000..49ef79cba3 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_01/expected.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "module", + "body": [ + { + "type": "DeclareFunction", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "foo" + }, + "name": "foo", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 20, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 20, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "typeParameters": null, + "params": [ + { + "type": "FunctionTypeParam", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "name": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "x" + }, + "name": "x" + }, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 30 + } + } + } + }, + { + "type": "FunctionTypeParam", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 41, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 45 + } + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_02/actual.js b/test/fixtures/flow/anonymous-function-types/good_02/actual.js new file mode 100644 index 0000000000..d3664c8c62 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_02/actual.js @@ -0,0 +1,2 @@ +// TODO: declare export syntax +// declare export function foo(x: number, string): void; diff --git a/test/fixtures/flow/anonymous-function-types/good_02/expected.json b/test/fixtures/flow/anonymous-function-types/good_02/expected.json new file mode 100644 index 0000000000..58d816578e --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_02/expected.json @@ -0,0 +1,102 @@ +{ + "type": "File", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "sourceType": "module", + "body": [], + "directives": [], + "leadingComments": null, + "innerComments": [ + { + "type": "CommentLine", + "value": " TODO: declare export syntax", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "CommentLine", + "value": " declare export function foo(x: number, string): void;", + "start": 31, + "end": 87, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 56 + } + } + } + ] + }, + "comments": [ + { + "type": "CommentLine", + "value": " TODO: declare export syntax", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "CommentLine", + "value": " declare export function foo(x: number, string): void;", + "start": 31, + "end": 87, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 56 + } + } + } + ] +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_03/actual.js b/test/fixtures/flow/anonymous-function-types/good_03/actual.js new file mode 100644 index 0000000000..d92d05d843 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_03/actual.js @@ -0,0 +1 @@ +type A = (string) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_03/expected.json b/test/fixtures/flow/anonymous-function-types/good_03/expected.json new file mode 100644 index 0000000000..f1827ba3db --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_03/expected.json @@ -0,0 +1,139 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 16, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 16 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 21, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_04/actual.js b/test/fixtures/flow/anonymous-function-types/good_04/actual.js new file mode 100644 index 0000000000..1025170b6d --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_04/actual.js @@ -0,0 +1 @@ +type A = (string,) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_04/expected.json b/test/fixtures/flow/anonymous-function-types/good_04/expected.json new file mode 100644 index 0000000000..c0fac4129f --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_04/expected.json @@ -0,0 +1,139 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 17, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 22, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_05/actual.js b/test/fixtures/flow/anonymous-function-types/good_05/actual.js new file mode 100644 index 0000000000..b0d08b1285 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_05/actual.js @@ -0,0 +1 @@ +type A = (Array) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_05/expected.json b/test/fixtures/flow/anonymous-function-types/good_05/expected.json new file mode 100644 index 0000000000..e3cd8c7bdb --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_05/expected.json @@ -0,0 +1,188 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 23, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 10, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "params": [ + { + "type": "StringTypeAnnotation", + "start": 16, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "Array" + }, + "name": "Array" + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 32 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_06/actual.js b/test/fixtures/flow/anonymous-function-types/good_06/actual.js new file mode 100644 index 0000000000..ef58131306 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_06/actual.js @@ -0,0 +1 @@ +type A = (Array,) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_06/expected.json b/test/fixtures/flow/anonymous-function-types/good_06/expected.json new file mode 100644 index 0000000000..1efda8367a --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_06/expected.json @@ -0,0 +1,188 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 24, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "end": { + "line": 1, + "column": 24 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 10, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "params": [ + { + "type": "StringTypeAnnotation", + "start": 16, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "Array" + }, + "name": "Array" + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 29, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 33 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_07/actual.js b/test/fixtures/flow/anonymous-function-types/good_07/actual.js new file mode 100644 index 0000000000..e7a8bfe428 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_07/actual.js @@ -0,0 +1 @@ +type A = (x: string, number) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_07/expected.json b/test/fixtures/flow/anonymous-function-types/good_07/expected.json new file mode 100644 index 0000000000..ba782c6a12 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_07/expected.json @@ -0,0 +1,181 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "name": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "optional": false, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 13, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 19 + } + } + } + }, + { + "type": "FunctionTypeParam", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_08/actual.js b/test/fixtures/flow/anonymous-function-types/good_08/actual.js new file mode 100644 index 0000000000..a61e1f9140 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_08/actual.js @@ -0,0 +1 @@ +type A = (...Array) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_08/expected.json b/test/fixtures/flow/anonymous-function-types/good_08/expected.json new file mode 100644 index 0000000000..420a17cb6e --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_08/expected.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "params": [], + "rest": { + "type": "FunctionTypeParam", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 18, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "params": [ + { + "type": "StringTypeAnnotation", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "Array" + }, + "name": "Array" + } + } + }, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 31, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 35 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_09/actual.js b/test/fixtures/flow/anonymous-function-types/good_09/actual.js new file mode 100644 index 0000000000..154926d346 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_09/actual.js @@ -0,0 +1 @@ +type A = (Array, ...Array) => void diff --git a/test/fixtures/flow/anonymous-function-types/good_09/expected.json b/test/fixtures/flow/anonymous-function-types/good_09/expected.json new file mode 100644 index 0000000000..e43f8049d0 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_09/expected.json @@ -0,0 +1,268 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "FunctionTypeAnnotation", + "start": 9, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 10, + "end": 24, + "loc": { + "start": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "end": { + "line": 1, + "column": 24 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 10, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "params": [ + { + "type": "StringTypeAnnotation", + "start": 16, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "Array" + }, + "name": "Array" + } + } + } + ], + "rest": { + "type": "FunctionTypeParam", + "start": 28, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 28, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 33, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "params": [ + { + "type": "StringTypeAnnotation", + "start": 34, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 40 + } + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "Array" + }, + "name": "Array" + } + } + }, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 46, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 50 + } + } + }, + "typeParameters": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_10/actual.js b/test/fixtures/flow/anonymous-function-types/good_10/actual.js new file mode 100644 index 0000000000..2752171622 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_10/actual.js @@ -0,0 +1 @@ +var f = (x): (x: number) => 123 => 123; diff --git a/test/fixtures/flow/anonymous-function-types/good_10/expected.json b/test/fixtures/flow/anonymous-function-types/good_10/expected.json new file mode 100644 index 0000000000..e522809a4c --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_10/expected.json @@ -0,0 +1,244 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 11, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 13, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "x" + }, + "name": "x" + }, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 23 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "NumericLiteralTypeAnnotation", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": 123, + "extra": { + "rawValue": 123, + "raw": "123" + } + }, + "typeParameters": null + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "NumericLiteral", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_11/actual.js b/test/fixtures/flow/anonymous-function-types/good_11/actual.js new file mode 100644 index 0000000000..098cdc5003 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_11/actual.js @@ -0,0 +1 @@ +var f = (): (number) => 123; diff --git a/test/fixtures/flow/anonymous-function-types/good_11/expected.json b/test/fixtures/flow/anonymous-function-types/good_11/expected.json new file mode 100644 index 0000000000..0cdbecd783 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_11/expected.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 10, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 13, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 19 + } + } + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [], + "body": { + "type": "NumericLiteral", + "start": 24, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_12/actual.js b/test/fixtures/flow/anonymous-function-types/good_12/actual.js new file mode 100644 index 0000000000..6569a7bd20 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_12/actual.js @@ -0,0 +1 @@ +var f = (): string | (number) => 123; diff --git a/test/fixtures/flow/anonymous-function-types/good_12/expected.json b/test/fixtures/flow/anonymous-function-types/good_12/expected.json new file mode 100644 index 0000000000..cd8dec7223 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_12/expected.json @@ -0,0 +1,186 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 10, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "typeAnnotation": { + "type": "UnionTypeAnnotation", + "start": 12, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "types": [ + { + "type": "StringTypeAnnotation", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "NumberTypeAnnotation", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 28 + } + } + } + ] + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [], + "body": { + "type": "NumericLiteral", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/anonymous-function-types/good_13/actual.js b/test/fixtures/flow/anonymous-function-types/good_13/actual.js new file mode 100644 index 0000000000..1050621243 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_13/actual.js @@ -0,0 +1 @@ +var f = (x): ((number) => 123) => 123; diff --git a/test/fixtures/flow/anonymous-function-types/good_13/expected.json b/test/fixtures/flow/anonymous-function-types/good_13/expected.json new file mode 100644 index 0000000000..0448cdbd22 --- /dev/null +++ b/test/fixtures/flow/anonymous-function-types/good_13/expected.json @@ -0,0 +1,234 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 11, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 15, + "end": 21, + "loc": { + "start": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "end": { + "line": 1, + "column": 21 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + ], + "rest": null, + "returnType": { + "type": "NumericLiteralTypeAnnotation", + "start": 26, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "value": 123, + "extra": { + "rawValue": 123, + "raw": "123" + } + }, + "typeParameters": null + } + }, + "id": null, + "generator": false, + "expression": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "NumericLiteral", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/type-annotations/127/actual.js b/test/fixtures/flow/type-annotations/127/actual.js new file mode 100644 index 0000000000..3846a5da3a --- /dev/null +++ b/test/fixtures/flow/type-annotations/127/actual.js @@ -0,0 +1 @@ +type A = { [string]: number }; diff --git a/test/fixtures/flow/type-annotations/127/expected.json b/test/fixtures/flow/type-annotations/127/expected.json new file mode 100644 index 0000000000..c9361209da --- /dev/null +++ b/test/fixtures/flow/type-annotations/127/expected.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "callProperties": [], + "properties": [], + "indexers": [ + { + "type": "ObjectTypeIndexer", + "start": 11, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "static": false, + "id": null, + "key": { + "type": "StringTypeAnnotation", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + "value": { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + "variance": null + } + ], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/flow/type-annotations/128/actual.js b/test/fixtures/flow/type-annotations/128/actual.js new file mode 100644 index 0000000000..dde03a4ef5 --- /dev/null +++ b/test/fixtures/flow/type-annotations/128/actual.js @@ -0,0 +1 @@ +type A = { [string | boolean]: number }; diff --git a/test/fixtures/flow/type-annotations/128/expected.json b/test/fixtures/flow/type-annotations/128/expected.json new file mode 100644 index 0000000000..76203fc324 --- /dev/null +++ b/test/fixtures/flow/type-annotations/128/expected.json @@ -0,0 +1,167 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "callProperties": [], + "properties": [], + "indexers": [ + { + "type": "ObjectTypeIndexer", + "start": 11, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "static": false, + "id": null, + "key": { + "type": "UnionTypeAnnotation", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "types": [ + { + "type": "StringTypeAnnotation", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "BooleanTypeAnnotation", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 28 + } + } + } + ] + }, + "value": { + "type": "NumberTypeAnnotation", + "start": 31, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 37 + } + } + }, + "variance": null + } + ], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file