diff --git a/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/input.js b/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/input.js index b42988128e04..0d7178b7b682 100644 --- a/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/input.js @@ -1,3 +1,4 @@ class MyClass { /*:: prop: string; */ + /* :: foo: number; */ } diff --git a/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/output.json b/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/output.json index 618209f10c9a..42033b969ac4 100644 --- a/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment-disabled/01-type-include/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 41, + "end": 68, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, "program": { "type": "Program", "start": 0, - "end": 41, + "end": 68, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -32,14 +32,14 @@ { "type": "ClassDeclaration", "start": 0, - "end": 41, + "end": 68, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -64,14 +64,14 @@ "body": { "type": "ClassBody", "start": 14, - "end": 41, + "end": 68, "loc": { "start": { "line": 1, "column": 14 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -92,6 +92,22 @@ "column": 23 } } + }, + { + "type": "CommentBlock", + "value": " :: foo: number; ", + "start": 42, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 26 + } + } } ] } @@ -115,6 +131,22 @@ "column": 23 } } + }, + { + "type": "CommentBlock", + "value": " :: foo: number; ", + "start": 42, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 26 + } + } } ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/input.js b/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/input.js index d1644a305b88..5391c499ba5f 100644 --- a/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/input.js @@ -1,4 +1,4 @@ -/*flow-include +/* flow-include type Foo = { foo: number, bar: boolean, diff --git a/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json b/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json index ed5a0e7b58b3..39c844aa9f01 100644 --- a/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 78, + "end": 79, "loc": { "start": { "line": 1, @@ -15,7 +15,7 @@ "program": { "type": "Program", "start": 0, - "end": 78, + "end": 79, "loc": { "start": { "line": 1, @@ -33,9 +33,9 @@ "innerComments": [ { "type": "CommentBlock", - "value": "flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n", + "value": " flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n", "start": 0, - "end": 78, + "end": 79, "loc": { "start": { "line": 1, @@ -52,9 +52,9 @@ "comments": [ { "type": "CommentBlock", - "value": "flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n", + "value": " flow-include\ntype Foo = {\n foo: number,\n bar: boolean,\n baz: string\n};\n", "start": 0, - "end": 78, + "end": 79, "loc": { "start": { "line": 1, diff --git a/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/input.js b/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/input.js index 6dc6ca809bfa..0e2022bb2d59 100644 --- a/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/input.js @@ -1,3 +1,4 @@ class MyClass { /*flow-include prop: string; */ + /* flow-include foo: number; */ } diff --git a/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json b/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json index fb2a67dd8393..8c2727c7eb82 100644 --- a/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 51, + "end": 90, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, "program": { "type": "Program", "start": 0, - "end": 51, + "end": 90, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -32,14 +32,14 @@ { "type": "ClassDeclaration", "start": 0, - "end": 51, + "end": 90, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -64,14 +64,14 @@ "body": { "type": "ClassBody", "start": 14, - "end": 51, + "end": 90, "loc": { "start": { "line": 1, "column": 14 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -92,6 +92,22 @@ "column": 33 } } + }, + { + "type": "CommentBlock", + "value": " flow-include foo: number; ", + "start": 52, + "end": 88, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 38 + } + } } ] } @@ -115,6 +131,22 @@ "column": 33 } } + }, + { + "type": "CommentBlock", + "value": " flow-include foo: number; ", + "start": 52, + "end": 88, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 38 + } + } } ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/comment/01-type-include/input.js b/packages/babel-parser/test/fixtures/flow/comment/01-type-include/input.js index b42988128e04..cca6b81303bf 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/01-type-include/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment/01-type-include/input.js @@ -1,3 +1,4 @@ class MyClass { - /*:: prop: string; */ + /* :: prop: string; */ + /* :: prop2: number; */ } diff --git a/packages/babel-parser/test/fixtures/flow/comment/01-type-include/output.json b/packages/babel-parser/test/fixtures/flow/comment/01-type-include/output.json index 4f80907e1de9..b31ea80c63cf 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/01-type-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment/01-type-include/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 41, + "end": 74, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, "program": { "type": "Program", "start": 0, - "end": 41, + "end": 74, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -32,14 +32,14 @@ { "type": "ClassDeclaration", "start": 0, - "end": 41, + "end": 74, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -64,45 +64,45 @@ "body": { "type": "ClassBody", "start": 14, - "end": 41, + "end": 74, "loc": { "start": { "line": 1, "column": 14 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, "body": [ { "type": "ClassProperty", - "start": 23, - "end": 36, + "start": 26, + "end": 39, "loc": { "start": { "line": 2, - "column": 7 + "column": 10 }, "end": { "line": 2, - "column": 20 + "column": 23 } }, "static": false, "key": { "type": "Identifier", - "start": 23, - "end": 27, + "start": 26, + "end": 30, "loc": { "start": { "line": 2, - "column": 7 + "column": 10 }, "end": { "line": 2, - "column": 11 + "column": 14 }, "identifierName": "prop" }, @@ -112,30 +112,96 @@ "variance": null, "typeAnnotation": { "type": "TypeAnnotation", - "start": 27, - "end": 35, + "start": 30, + "end": 38, "loc": { "start": { "line": 2, - "column": 11 + "column": 14 }, "end": { "line": 2, - "column": 19 + "column": 22 } }, "typeAnnotation": { "type": "StringTypeAnnotation", - "start": 29, - "end": 35, + "start": 32, + "end": 38, "loc": { "start": { "line": 2, - "column": 13 + "column": 16 }, "end": { "line": 2, + "column": 22 + } + } + } + }, + "value": null + }, + { + "type": "ClassProperty", + "start": 55, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 55, + "end": 60, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 17 + }, + "identifierName": "prop2" + }, + "name": "prop2" + }, + "computed": false, + "variance": null, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 60, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 62, + "end": 68, + "loc": { + "start": { + "line": 3, "column": 19 + }, + "end": { + "line": 3, + "column": 25 } } } diff --git a/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/input.js b/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/input.js index d1644a305b88..5391c499ba5f 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/input.js @@ -1,4 +1,4 @@ -/*flow-include +/* flow-include type Foo = { foo: number, bar: boolean, diff --git a/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json b/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json index 5b41ff77f72a..567f48a615b3 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 78, + "end": 79, "loc": { "start": { "line": 1, @@ -15,7 +15,7 @@ "program": { "type": "Program", "start": 0, - "end": 78, + "end": 79, "loc": { "start": { "line": 1, @@ -31,8 +31,8 @@ "body": [ { "type": "TypeAlias", - "start": 15, - "end": 75, + "start": 16, + "end": 76, "loc": { "start": { "line": 2, @@ -45,8 +45,8 @@ }, "id": { "type": "Identifier", - "start": 20, - "end": 23, + "start": 21, + "end": 24, "loc": { "start": { "line": 2, @@ -63,8 +63,8 @@ "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 26, - "end": 74, + "start": 27, + "end": 75, "loc": { "start": { "line": 2, @@ -79,8 +79,8 @@ "properties": [ { "type": "ObjectTypeProperty", - "start": 30, - "end": 41, + "start": 31, + "end": 42, "loc": { "start": { "line": 3, @@ -93,8 +93,8 @@ }, "key": { "type": "Identifier", - "start": 30, - "end": 33, + "start": 31, + "end": 34, "loc": { "start": { "line": 3, @@ -114,8 +114,8 @@ "method": false, "value": { "type": "NumberTypeAnnotation", - "start": 35, - "end": 41, + "start": 36, + "end": 42, "loc": { "start": { "line": 3, @@ -132,8 +132,8 @@ }, { "type": "ObjectTypeProperty", - "start": 45, - "end": 57, + "start": 46, + "end": 58, "loc": { "start": { "line": 4, @@ -146,8 +146,8 @@ }, "key": { "type": "Identifier", - "start": 45, - "end": 48, + "start": 46, + "end": 49, "loc": { "start": { "line": 4, @@ -167,8 +167,8 @@ "method": false, "value": { "type": "BooleanTypeAnnotation", - "start": 50, - "end": 57, + "start": 51, + "end": 58, "loc": { "start": { "line": 4, @@ -185,8 +185,8 @@ }, { "type": "ObjectTypeProperty", - "start": 61, - "end": 72, + "start": 62, + "end": 73, "loc": { "start": { "line": 5, @@ -199,8 +199,8 @@ }, "key": { "type": "Identifier", - "start": 61, - "end": 64, + "start": 62, + "end": 65, "loc": { "start": { "line": 5, @@ -220,8 +220,8 @@ "method": false, "value": { "type": "StringTypeAnnotation", - "start": 66, - "end": 72, + "start": 67, + "end": 73, "loc": { "start": { "line": 5, diff --git a/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/input.js b/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/input.js index 6dc6ca809bfa..7c3c07ea0945 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/input.js @@ -1,3 +1,4 @@ class MyClass { - /*flow-include prop: string; */ + /* flow-include prop: string; */ + /* flow-include prop2: number; */ } diff --git a/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/output.json b/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/output.json index fb2a67dd8393..908bfa823b79 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment/04-type-flow-include/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 51, + "end": 99, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, "program": { "type": "Program", "start": 0, - "end": 51, + "end": 99, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -32,14 +32,14 @@ { "type": "ClassDeclaration", "start": 0, - "end": 51, + "end": 99, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, @@ -64,57 +64,154 @@ "body": { "type": "ClassBody", "start": 14, - "end": 51, + "end": 99, "loc": { "start": { "line": 1, "column": 14 }, "end": { - "line": 3, + "line": 4, "column": 1 } }, - "body": [], - "innerComments": [ + "body": [ { - "type": "CommentBlock", - "value": "flow-include prop: string; ", - "start": 18, - "end": 49, + "type": "ClassProperty", + "start": 39, + "end": 52, "loc": { "start": { "line": 2, - "column": 2 + "column": 23 }, "end": { "line": 2, - "column": 33 + "column": 36 } - } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 39, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 27 + }, + "identifierName": "prop" + }, + "name": "prop" + }, + "computed": false, + "variance": null, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 43, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 45, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 + } + } + } + }, + "value": null + }, + { + "type": "ClassProperty", + "start": 80, + "end": 94, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 38 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 80, + "end": 85, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + }, + "identifierName": "prop2" + }, + "name": "prop2" + }, + "computed": false, + "variance": null, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 85, + "end": 93, + "loc": { + "start": { + "line": 3, + "column": 29 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 87, + "end": 93, + "loc": { + "start": { + "line": 3, + "column": 31 + }, + "end": { + "line": 3, + "column": 37 + } + } + } + }, + "value": null } ] } } ], "directives": [] - }, - "comments": [ - { - "type": "CommentBlock", - "value": "flow-include prop: string; ", - "start": 18, - "end": 49, - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 33 - } - } - } - ] + } } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/comment/06-type-include-error/input.js b/packages/babel-parser/test/fixtures/flow/comment/06-type-include-error/input.js index 24b92dba6ee5..38ca508e980d 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/06-type-include-error/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment/06-type-include-error/input.js @@ -1,3 +1,3 @@ class MyClass { - /*:: prop: string; + /* :: prop: string; } diff --git a/packages/babel-parser/test/fixtures/flow/comment/08-type-flow-include-error/input.js b/packages/babel-parser/test/fixtures/flow/comment/08-type-flow-include-error/input.js index 495661d6a0ac..e876bde46b18 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/08-type-flow-include-error/input.js +++ b/packages/babel-parser/test/fixtures/flow/comment/08-type-flow-include-error/input.js @@ -1,4 +1,4 @@ -/*flow-include +/* flow-include type Foo = { foo: number, bar: boolean,