diff --git a/Makefile b/Makefile index 325866dea3cf..e4168eb2c3ee 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ MAKEFLAGS = -j1 -FLOW_COMMIT = bea8b83f50f597454941d2a7ecef6e93a881e576 +FLOW_COMMIT = e192e1a4793dd8e43415fbfe8046d832cb513c8b TEST262_COMMIT = 06c2f019019cf7850923de4d56828e6dfd9212b8 # Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967 @@ -82,7 +82,7 @@ test-ci-coverage: bootstrap-flow: rm -rf ./build/flow mkdir -p ./build - git clone --branch=master --single-branch --shallow-since=2017-01-01 https://github.com/facebook/flow.git ./build/flow + git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git ./build/flow cd build/flow && git checkout $(FLOW_COMMIT) test-flow: diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index cd250e9ad085..79edbc0f9751 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -23,6 +23,9 @@ const primitiveTypes = [ "true", "typeof", "void", + "interface", + "extends", + "_", ]; function isEsModuleType(bodyElement: N.Node): boolean { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_allowed_trailing_commas/input.js b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_allowed_trailing_commas/input.js new file mode 100644 index 000000000000..364601fa788d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_allowed_trailing_commas/input.js @@ -0,0 +1,8 @@ +//@flow +test< + _, + _, + number, + _, + _, +>(); diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_allowed_trailing_commas/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_allowed_trailing_commas/output.json new file mode 100644 index 000000000000..e30f8a938f73 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_allowed_trailing_commas/output.json @@ -0,0 +1,283 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 8, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "expression": { + "type": "CallExpression", + "start": 8, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 3 + } + }, + "callee": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "test" + }, + "name": "test" + }, + "typeArguments": { + "type": "TypeParameterInstantiation", + "start": 12, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "params": [ + { + "type": "GenericTypeAnnotation", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "NumberTypeAnnotation", + "start": 26, + "end": 32, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 8 + } + } + }, + { + "type": "GenericTypeAnnotation", + "start": 36, + "end": 37, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 36, + "end": 37, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + }, + "identifierName": "_" + }, + "name": "_" + } + } + ] + }, + "arguments": [] + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_implicit_anywhere_in_list/input.js b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_implicit_anywhere_in_list/input.js new file mode 100644 index 000000000000..b9aaa5913aa2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_implicit_anywhere_in_list/input.js @@ -0,0 +1,2 @@ +//@flow +test(); diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_implicit_anywhere_in_list/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_implicit_anywhere_in_list/output.json new file mode 100644 index 000000000000..7b90b530ad65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/underscore_is_implicit_anywhere_in_list/output.json @@ -0,0 +1,397 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 8, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "expression": { + "type": "CallExpression", + "start": 8, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 49 + } + }, + "callee": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "test" + }, + "name": "test" + }, + "typeArguments": { + "type": "TypeParameterInstantiation", + "start": 12, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 47 + } + }, + "params": [ + { + "type": "NumberTypeAnnotation", + "start": 13, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "GenericTypeAnnotation", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "StringTypeAnnotation", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "GenericTypeAnnotation", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 36 + }, + "identifierName": "Foo" + }, + "name": "Foo" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + }, + "identifierName": "Bar" + }, + "name": "Bar" + } + }, + { + "type": "GenericTypeAnnotation", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 46 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 46 + }, + "identifierName": "Baz" + }, + "name": "Baz" + } + } + ] + }, + "arguments": [] + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file