diff --git a/packages/babylon/src/parser/comments.js b/packages/babylon/src/parser/comments.js index 6bc7e2b2f9..ec8f22dd90 100644 --- a/packages/babylon/src/parser/comments.js +++ b/packages/babylon/src/parser/comments.js @@ -64,16 +64,14 @@ export default class CommentsParser extends BaseParser { // later. this.state.trailingComments.length = 0; } - } else { - if (stack.length > 0) { - const lastInStack = last(stack); - if ( - lastInStack.trailingComments && - lastInStack.trailingComments[0].start >= node.end - ) { - trailingComments = lastInStack.trailingComments; - lastInStack.trailingComments = null; - } + } else if (stack.length > 0) { + const lastInStack = last(stack); + if ( + lastInStack.trailingComments && + lastInStack.trailingComments[0].start >= node.end + ) { + trailingComments = lastInStack.trailingComments; + delete lastInStack.trailingComments; } } @@ -143,7 +141,7 @@ export default class CommentsParser extends BaseParser { last(lastChild.leadingComments).end <= node.start ) { node.leadingComments = lastChild.leadingComments; - lastChild.leadingComments = null; + delete lastChild.leadingComments; } else { // A leading comment for an anonymous class had been stolen by its first ClassMethod, // so this takes back the leading comment. @@ -196,8 +194,10 @@ export default class CommentsParser extends BaseParser { // result in an empty array, and if so, the array must be // deleted. const leadingComments = this.state.leadingComments.slice(0, i); - node.leadingComments = - leadingComments.length === 0 ? null : leadingComments; + + if (leadingComments.length) { + node.leadingComments = leadingComments; + } // Similarly, trailing comments are attached later. The variable // must be reset to null if there are no trailing comments. diff --git a/packages/babylon/src/parser/node.js b/packages/babylon/src/parser/node.js index 3ddd6038c2..422a26a2ae 100644 --- a/packages/babylon/src/parser/node.js +++ b/packages/babylon/src/parser/node.js @@ -24,9 +24,9 @@ class Node implements NodeBase { end: number; loc: SourceLocation; range: [number, number]; - leadingComments: ?Array; - trailingComments: ?Array; - innerComments: ?Array; + leadingComments: Array; + trailingComments: Array; + innerComments: Array; extra: { [key: string]: any }; __clone(): this { diff --git a/packages/babylon/src/types.js b/packages/babylon/src/types.js index 7b30b56604..a777716dd5 100644 --- a/packages/babylon/src/types.js +++ b/packages/babylon/src/types.js @@ -26,9 +26,9 @@ export interface NodeBase { end: number; loc: SourceLocation; range: [number, number]; - leadingComments?: ?Array; - trailingComments?: ?Array; - innerComments?: ?Array; + leadingComments?: Array; + trailingComments?: Array; + innerComments?: Array; extra: { [key: string]: any }; } diff --git a/packages/babylon/test/expressions/is-expression-babylon/pass/5/output.json b/packages/babylon/test/expressions/is-expression-babylon/pass/5/output.json index b42fcb7c0b..730287d883 100644 --- a/packages/babylon/test/expressions/is-expression-babylon/pass/5/output.json +++ b/packages/babylon/test/expressions/is-expression-babylon/pass/5/output.json @@ -14,7 +14,6 @@ "identifierName": "abc" }, "name": "abc", - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/comments/basic/export-default-anonymous-class/output.json b/packages/babylon/test/fixtures/comments/basic/export-default-anonymous-class/output.json index d33bb43b35..4303340faf 100644 --- a/packages/babylon/test/fixtures/comments/basic/export-default-anonymous-class/output.json +++ b/packages/babylon/test/fixtures/comments/basic/export-default-anonymous-class/output.json @@ -103,8 +103,7 @@ }, "identifierName": "method1" }, - "name": "method1", - "leadingComments": null + "name": "method1" }, "computed": false, "kind": "method", @@ -148,10 +147,8 @@ } ] } - ], - "leadingComments": null - }, - "leadingComments": null + ] + } }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/comments/basic/object-property-trailing-comma/output.json b/packages/babylon/test/fixtures/comments/basic/object-property-trailing-comma/output.json index c34ab8f89d..5d8fcfff6f 100644 --- a/packages/babylon/test/fixtures/comments/basic/object-property-trailing-comma/output.json +++ b/packages/babylon/test/fixtures/comments/basic/object-property-trailing-comma/output.json @@ -174,8 +174,7 @@ }, "identifierName": "b" }, - "name": "b", - "leadingComments": null + "name": "b" }, "computed": false, "shorthand": false, @@ -248,8 +247,7 @@ }, "identifierName": "c" }, - "name": "c", - "leadingComments": null + "name": "c" }, "computed": false, "shorthand": false, diff --git a/packages/babylon/test/fixtures/comments/basic/shebang-import/output.json b/packages/babylon/test/fixtures/comments/basic/shebang-import/output.json index 0a4d4d6663..b22a2f74d0 100644 --- a/packages/babylon/test/fixtures/comments/basic/shebang-import/output.json +++ b/packages/babylon/test/fixtures/comments/basic/shebang-import/output.json @@ -72,8 +72,7 @@ }, "identifierName": "spawn" }, - "name": "spawn", - "leadingComments": null + "name": "spawn" }, "local": { "type": "Identifier", @@ -91,8 +90,7 @@ "identifierName": "spawn" }, "name": "spawn" - }, - "leadingComments": null + } } ], "source": { diff --git a/packages/babylon/test/fixtures/comments/basic/shebang-object/output.json b/packages/babylon/test/fixtures/comments/basic/shebang-object/output.json index bf2ed2a6d6..771533fc5f 100644 --- a/packages/babylon/test/fixtures/comments/basic/shebang-object/output.json +++ b/packages/babylon/test/fixtures/comments/basic/shebang-object/output.json @@ -102,8 +102,7 @@ }, "identifierName": "spawn" }, - "name": "spawn", - "leadingComments": null + "name": "spawn" }, "computed": false, "shorthand": true, @@ -124,13 +123,11 @@ }, "name": "spawn" }, - "leadingComments": null, "extra": { "shorthand": true } } - ], - "leadingComments": null + ] }, "init": { "type": "Identifier", @@ -148,8 +145,7 @@ "identifierName": "x" }, "name": "x" - }, - "leadingComments": null + } } ], "kind": "var", diff --git a/packages/babylon/test/fixtures/comments/basic/surrounding-call-comments/output.json b/packages/babylon/test/fixtures/comments/basic/surrounding-call-comments/output.json index 6d981c4e8f..0eeda94a6f 100644 --- a/packages/babylon/test/fixtures/comments/basic/surrounding-call-comments/output.json +++ b/packages/babylon/test/fixtures/comments/basic/surrounding-call-comments/output.json @@ -120,11 +120,9 @@ }, "identifierName": "foo" }, - "name": "foo", - "leadingComments": null + "name": "foo" }, - "arguments": [], - "leadingComments": null + "arguments": [] }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/comments/basic/surrounding-throw-comments/output.json b/packages/babylon/test/fixtures/comments/basic/surrounding-throw-comments/output.json index 5a49d03040..137eb321c1 100644 --- a/packages/babylon/test/fixtures/comments/basic/surrounding-throw-comments/output.json +++ b/packages/babylon/test/fixtures/comments/basic/surrounding-throw-comments/output.json @@ -109,8 +109,7 @@ "rawValue": 55, "raw": "55" }, - "value": 55, - "leadingComments": null + "value": 55 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/comments/basic/surrounding-while-loop-comments/output.json b/packages/babylon/test/fixtures/comments/basic/surrounding-while-loop-comments/output.json index 5cbea1bbf7..e570c51350 100644 --- a/packages/babylon/test/fixtures/comments/basic/surrounding-while-loop-comments/output.json +++ b/packages/babylon/test/fixtures/comments/basic/surrounding-while-loop-comments/output.json @@ -105,8 +105,7 @@ "column": 41 } }, - "value": true, - "leadingComments": null + "value": true }, "body": { "type": "BlockStatement", @@ -123,9 +122,7 @@ } }, "body": [], - "directives": [], - "leadingComments": null, - "trailingComments": null + "directives": [] }, "leadingComments": [ { @@ -208,11 +205,9 @@ }, "identifierName": "each" }, - "name": "each", - "leadingComments": null + "name": "each" }, - "init": null, - "leadingComments": null + "init": null } ], "kind": "var", diff --git a/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment-in-function/output.json b/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment-in-function/output.json index 19b410da11..1c815f43fe 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment-in-function/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment-in-function/output.json @@ -160,8 +160,7 @@ "rawValue": 1, "raw": "1" }, - "value": 1, - "leadingComments": null + "value": 1 }, "leadingComments": [ { @@ -282,8 +281,7 @@ "rawValue": 2, "raw": "2" }, - "value": 2, - "leadingComments": null + "value": 2 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment/output.json b/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment/output.json index 1e6c9d5796..1c84a8542f 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-fallthrough-comment/output.json @@ -93,8 +93,7 @@ "rawValue": 1, "raw": "1" }, - "value": 1, - "leadingComments": null + "value": 1 }, "leadingComments": [ { @@ -215,8 +214,7 @@ "rawValue": 2, "raw": "2" }, - "value": 2, - "leadingComments": null + "value": 2 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon-no-default/output.json b/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon-no-default/output.json index afde57632b..35d92cc5b3 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon-no-default/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon-no-default/output.json @@ -174,10 +174,8 @@ }, "value": "1" } - ], - "trailingComments": null - }, - "trailingComments": null + ] + } } ], "test": { diff --git a/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon/output.json b/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon/output.json index 5f05d417be..eb44ef2e1e 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-function-call-no-semicolon/output.json @@ -174,10 +174,8 @@ }, "value": "1" } - ], - "trailingComments": null - }, - "trailingComments": null + ] + } } ], "test": { @@ -248,8 +246,7 @@ "column": 10 } }, - "label": null, - "leadingComments": null + "label": null } ], "test": null, diff --git a/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-function/output.json b/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-function/output.json index 93335c8ea6..39391549f3 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-function/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-function/output.json @@ -209,9 +209,7 @@ "column": 18 } }, - "label": null, - "leadingComments": null, - "trailingComments": null + "label": null } ], "test": { diff --git a/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-nested-functions/output.json b/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-nested-functions/output.json index 9e74ce4779..14036c1932 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-nested-functions/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment-in-nested-functions/output.json @@ -537,8 +537,7 @@ "computed": true } ] - }, - "trailingComments": null + } } ], "test": { diff --git a/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment/output.json b/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment/output.json index 99e1057f70..1d9bf05557 100644 --- a/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment/output.json +++ b/packages/babylon/test/fixtures/comments/basic/switch-no-default-comment/output.json @@ -89,9 +89,7 @@ "column": 14 } }, - "label": null, - "leadingComments": null, - "trailingComments": null + "label": null } ], "test": { diff --git a/packages/babylon/test/fixtures/core/categorized/filename-specified/output.json b/packages/babylon/test/fixtures/core/categorized/filename-specified/output.json index 2269e0729d..71b5c63f0f 100644 --- a/packages/babylon/test/fixtures/core/categorized/filename-specified/output.json +++ b/packages/babylon/test/fixtures/core/categorized/filename-specified/output.json @@ -77,8 +77,7 @@ "filename": "path/to/input-file.js", "identifierName": "node" }, - "name": "node", - "leadingComments": null + "name": "node" }, "init": { "type": "StringLiteral", @@ -100,8 +99,7 @@ "raw": "\"shouldHaveFilenameLocProp\"" }, "value": "shouldHaveFilenameLocProp" - }, - "leadingComments": null + } } ], "kind": "var", diff --git a/packages/babylon/test/fixtures/core/uncategorised/302/output.json b/packages/babylon/test/fixtures/core/uncategorised/302/output.json index 3840e25325..980da318b2 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/302/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/302/output.json @@ -72,9 +72,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null, - "trailingComments": null + "name": "x" }, "init": null, "trailingComments": [ diff --git a/packages/babylon/test/fixtures/core/uncategorised/305/output.json b/packages/babylon/test/fixtures/core/uncategorised/305/output.json index fd7f41293b..fa6e6d72ad 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/305/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/305/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/306/output.json b/packages/babylon/test/fixtures/core/uncategorised/306/output.json index 820264c6d1..62aa8e6c96 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/306/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/306/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/308/output.json b/packages/babylon/test/fixtures/core/uncategorised/308/output.json index b5794cac3a..5b8445270a 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/308/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/308/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/309/output.json b/packages/babylon/test/fixtures/core/uncategorised/309/output.json index 62b72404df..e133a3d9f3 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/309/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/309/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/311/output.json b/packages/babylon/test/fixtures/core/uncategorised/311/output.json index 596e242872..8dabaf1b27 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/311/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/311/output.json @@ -90,7 +90,6 @@ } }, "argument": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", @@ -139,8 +138,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/312/output.json b/packages/babylon/test/fixtures/core/uncategorised/312/output.json index 8cc2cff071..7299ca692d 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/312/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/312/output.json @@ -90,7 +90,6 @@ } }, "argument": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", @@ -139,8 +138,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/314/output.json b/packages/babylon/test/fixtures/core/uncategorised/314/output.json index 55562ff024..ca775c6565 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/314/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/314/output.json @@ -72,9 +72,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null, - "trailingComments": null + "name": "error" }, "trailingComments": [ { @@ -124,8 +122,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null + "name": "error" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/315/output.json b/packages/babylon/test/fixtures/core/uncategorised/315/output.json index acb5183a09..011c8cd343 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/315/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/315/output.json @@ -72,9 +72,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null, - "trailingComments": null + "name": "error" }, "trailingComments": [ { @@ -124,8 +122,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null + "name": "error" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/342/output.json b/packages/babylon/test/fixtures/core/uncategorised/342/output.json index 4501a541b5..2f528099d8 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/342/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/342/output.json @@ -72,7 +72,6 @@ "identifierName": "foo" }, "name": "foo", - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/core/uncategorised/46/output.json b/packages/babylon/test/fixtures/core/uncategorised/46/output.json index 066268b734..0b9bf82517 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/46/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/46/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/47/output.json b/packages/babylon/test/fixtures/core/uncategorised/47/output.json index c4b3d4e650..a5e99552b7 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/47/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/47/output.json @@ -60,9 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null, - "trailingComments": null + "value": 42 }, "trailingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/48/output.json b/packages/babylon/test/fixtures/core/uncategorised/48/output.json index b4f2a6c022..86ca6e88fb 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/48/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/48/output.json @@ -60,9 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null, - "trailingComments": null + "value": 42 }, "trailingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/49/output.json b/packages/babylon/test/fixtures/core/uncategorised/49/output.json index b305381271..f6a3b9569e 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/49/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/49/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/50/output.json b/packages/babylon/test/fixtures/core/uncategorised/50/output.json index b9ae8a60ef..6bd86a2204 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/50/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/50/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/51/output.json b/packages/babylon/test/fixtures/core/uncategorised/51/output.json index f0020ece82..9f490fe1c2 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/51/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/51/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/52/output.json b/packages/babylon/test/fixtures/core/uncategorised/52/output.json index b9ae8a60ef..6bd86a2204 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/52/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/52/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/53/output.json b/packages/babylon/test/fixtures/core/uncategorised/53/output.json index 8d036e8eec..73f79dd052 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/53/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/53/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/54/output.json b/packages/babylon/test/fixtures/core/uncategorised/54/output.json index 9155b188e0..bd6d42ab55 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/54/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/54/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/55/output.json b/packages/babylon/test/fixtures/core/uncategorised/55/output.json index e063174f83..ee70683b87 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/55/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/55/output.json @@ -60,9 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null, - "trailingComments": null + "value": 42 }, "trailingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/56/output.json b/packages/babylon/test/fixtures/core/uncategorised/56/output.json index 8b4ec7b146..b5dbc9c524 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/56/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/56/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/57/output.json b/packages/babylon/test/fixtures/core/uncategorised/57/output.json index df3b3c2419..8527f9fa67 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/57/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/57/output.json @@ -29,7 +29,6 @@ "sourceType": "script", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/core/uncategorised/58/output.json b/packages/babylon/test/fixtures/core/uncategorised/58/output.json index b932885f57..c0a55f3e8a 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/58/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/58/output.json @@ -29,7 +29,6 @@ "sourceType": "script", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/core/uncategorised/59/output.json b/packages/babylon/test/fixtures/core/uncategorised/59/output.json index e5abba24ef..d70bf78c55 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/59/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/59/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/60/output.json b/packages/babylon/test/fixtures/core/uncategorised/60/output.json index b58673ec8e..32fedf457e 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/60/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/60/output.json @@ -29,7 +29,6 @@ "sourceType": "script", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/core/uncategorised/61/output.json b/packages/babylon/test/fixtures/core/uncategorised/61/output.json index b58673ec8e..32fedf457e 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/61/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/61/output.json @@ -29,7 +29,6 @@ "sourceType": "script", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/core/uncategorised/62/output.json b/packages/babylon/test/fixtures/core/uncategorised/62/output.json index 535a920ab7..e56f6adddd 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/62/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/62/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/63/output.json b/packages/babylon/test/fixtures/core/uncategorised/63/output.json index d2e809466f..7a01702255 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/63/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/63/output.json @@ -60,8 +60,7 @@ "rawValue": 42, "raw": "42" }, - "value": 42, - "leadingComments": null + "value": 42 }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/64/output.json b/packages/babylon/test/fixtures/core/uncategorised/64/output.json index 9c1a6d4b50..25bd74fc16 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/64/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/64/output.json @@ -117,11 +117,9 @@ }, "identifierName": "doThat" }, - "name": "doThat", - "leadingComments": null + "name": "doThat" }, - "arguments": [], - "leadingComments": null + "arguments": [] }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/core/uncategorised/65/output.json b/packages/babylon/test/fixtures/core/uncategorised/65/output.json index dfcf35acfe..129e2b720c 100644 --- a/packages/babylon/test/fixtures/core/uncategorised/65/output.json +++ b/packages/babylon/test/fixtures/core/uncategorised/65/output.json @@ -118,11 +118,9 @@ }, "identifierName": "bingo" }, - "name": "bingo", - "leadingComments": null + "name": "bingo" }, - "arguments": [], - "leadingComments": null + "arguments": [] }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/es2015/modules/xml-comment-in-script/output.json b/packages/babylon/test/fixtures/es2015/modules/xml-comment-in-script/output.json index 58dd94ffda..6b1974ec4b 100644 --- a/packages/babylon/test/fixtures/es2015/modules/xml-comment-in-script/output.json +++ b/packages/babylon/test/fixtures/es2015/modules/xml-comment-in-script/output.json @@ -57,9 +57,7 @@ }, "identifierName": "foo" }, - "name": "foo", - "leadingComments": null, - "trailingComments": null + "name": "foo" }, "trailingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0002/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0002/output.json index 3840e25325..980da318b2 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0002/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0002/output.json @@ -72,9 +72,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null, - "trailingComments": null + "name": "x" }, "init": null, "trailingComments": [ diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0005/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0005/output.json index fd7f41293b..fa6e6d72ad 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0005/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0005/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0006/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0006/output.json index 820264c6d1..62aa8e6c96 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0006/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0006/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0008/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0008/output.json index b5794cac3a..5b8445270a 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0008/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0008/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0009/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0009/output.json index 62b72404df..e133a3d9f3 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0009/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0009/output.json @@ -88,7 +88,6 @@ } }, "label": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", @@ -137,8 +136,7 @@ }, "identifierName": "there" }, - "name": "there", - "leadingComments": null + "name": "there" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0011/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0011/output.json index 596e242872..8dabaf1b27 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0011/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0011/output.json @@ -90,7 +90,6 @@ } }, "argument": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentLine", @@ -139,8 +138,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0012/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0012/output.json index 8cc2cff071..7299ca692d 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0012/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0012/output.json @@ -90,7 +90,6 @@ } }, "argument": null, - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", @@ -139,8 +138,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0014/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0014/output.json index 55562ff024..ca775c6565 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0014/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0014/output.json @@ -72,9 +72,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null, - "trailingComments": null + "name": "error" }, "trailingComments": [ { @@ -124,8 +122,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null + "name": "error" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0015/output.json b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0015/output.json index acb5183a09..011c8cd343 100644 --- a/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0015/output.json +++ b/packages/babylon/test/fixtures/esprima/automatic-semicolon-insertion/migrated_0015/output.json @@ -72,9 +72,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null, - "trailingComments": null + "name": "error" }, "trailingComments": [ { @@ -124,8 +122,7 @@ }, "identifierName": "error" }, - "name": "error", - "leadingComments": null + "name": "error" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/flow/anonymous-function-types/good_02/output.json b/packages/babylon/test/fixtures/flow/anonymous-function-types/good_02/output.json index 58d816578e..058834d851 100644 --- a/packages/babylon/test/fixtures/flow/anonymous-function-types/good_02/output.json +++ b/packages/babylon/test/fixtures/flow/anonymous-function-types/good_02/output.json @@ -29,7 +29,6 @@ "sourceType": "module", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/flow/comment-disabled/01-type-include/output.json b/packages/babylon/test/fixtures/flow/comment-disabled/01-type-include/output.json index 0946d0fca4..f5befcfbc0 100644 --- a/packages/babylon/test/fixtures/flow/comment-disabled/01-type-include/output.json +++ b/packages/babylon/test/fixtures/flow/comment-disabled/01-type-include/output.json @@ -75,7 +75,6 @@ } }, "body": [], - "leadingComments": null, "innerComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/flow/comment-disabled/02-type-include/output.json b/packages/babylon/test/fixtures/flow/comment-disabled/02-type-include/output.json index c54b11f4f6..e899eaaf3a 100644 --- a/packages/babylon/test/fixtures/flow/comment-disabled/02-type-include/output.json +++ b/packages/babylon/test/fixtures/flow/comment-disabled/02-type-include/output.json @@ -29,7 +29,6 @@ "sourceType": "module", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json b/packages/babylon/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json index e20f18a473..a57081c3bf 100644 --- a/packages/babylon/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json +++ b/packages/babylon/test/fixtures/flow/comment-disabled/03-type-flow-include/output.json @@ -29,7 +29,6 @@ "sourceType": "module", "body": [], "directives": [], - "leadingComments": null, "innerComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json b/packages/babylon/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json index 813c160d1a..72244409b0 100644 --- a/packages/babylon/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json +++ b/packages/babylon/test/fixtures/flow/comment-disabled/04-type-flow-include/output.json @@ -75,7 +75,6 @@ } }, "body": [], - "leadingComments": null, "innerComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/flow/comment-disabled/05-type-annotation/output.json b/packages/babylon/test/fixtures/flow/comment-disabled/05-type-annotation/output.json index 263df904eb..35d169d140 100644 --- a/packages/babylon/test/fixtures/flow/comment-disabled/05-type-annotation/output.json +++ b/packages/babylon/test/fixtures/flow/comment-disabled/05-type-annotation/output.json @@ -78,7 +78,6 @@ "identifierName": "param" }, "name": "param", - "leadingComments": null, "trailingComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/flow/comment/04-type-flow-include/output.json b/packages/babylon/test/fixtures/flow/comment/04-type-flow-include/output.json index 813c160d1a..72244409b0 100644 --- a/packages/babylon/test/fixtures/flow/comment/04-type-flow-include/output.json +++ b/packages/babylon/test/fixtures/flow/comment/04-type-flow-include/output.json @@ -75,7 +75,6 @@ } }, "body": [], - "leadingComments": null, "innerComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/flow/comment/spread/output.json b/packages/babylon/test/fixtures/flow/comment/spread/output.json index f2a0db913c..99b1f8e94d 100644 --- a/packages/babylon/test/fixtures/flow/comment/spread/output.json +++ b/packages/babylon/test/fixtures/flow/comment/spread/output.json @@ -57,8 +57,7 @@ }, "identifierName": "commentsAttachedToIdentifier" }, - "name": "commentsAttachedToIdentifier", - "leadingComments": null + "name": "commentsAttachedToIdentifier" }, "generator": false, "async": false, diff --git a/packages/babylon/test/fixtures/flow/regression/issue-58/output.json b/packages/babylon/test/fixtures/flow/regression/issue-58/output.json index ea2faebfbc..10d671667d 100644 --- a/packages/babylon/test/fixtures/flow/regression/issue-58/output.json +++ b/packages/babylon/test/fixtures/flow/regression/issue-58/output.json @@ -71,8 +71,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "Identifier", @@ -148,8 +147,7 @@ }, "name": "d" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -231,8 +229,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -353,8 +350,7 @@ "identifierName": "e" }, "name": "e" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -436,8 +432,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "Identifier", @@ -562,8 +557,7 @@ }, "name": "e" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -661,8 +655,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "AssignmentExpression", @@ -808,8 +801,7 @@ }, "name": "f" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -907,8 +899,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -1098,8 +1089,7 @@ "identifierName": "g" }, "name": "g" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -1197,8 +1187,7 @@ }, "identifierName": "b" }, - "name": "b", - "leadingComments": null + "name": "b" }, "consequent": { "type": "ConditionalExpression", @@ -1372,8 +1361,7 @@ "identifierName": "h" }, "name": "h" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -1471,8 +1459,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ConditionalExpression", @@ -1650,8 +1637,7 @@ "identifierName": "h" }, "name": "h" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -1733,8 +1719,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ConditionalExpression", @@ -1908,8 +1893,7 @@ "identifierName": "g" }, "name": "g" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -2007,8 +1991,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -2215,8 +2198,7 @@ }, "name": "g" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -2330,8 +2312,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -2538,8 +2519,7 @@ "identifierName": "g" }, "name": "g" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -2637,8 +2617,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "Identifier", @@ -2834,8 +2813,7 @@ ] } } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -2917,8 +2895,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -3114,8 +3091,7 @@ }, "name": "f" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -3213,8 +3189,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -3327,8 +3302,7 @@ }, "name": "e" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -3426,8 +3400,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ConditionalExpression", @@ -3589,8 +3562,7 @@ "identifierName": "g" }, "name": "g" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -3688,8 +3660,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -3888,8 +3859,7 @@ }, "name": "g" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -3987,8 +3957,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ConditionalExpression", @@ -4228,8 +4197,7 @@ }, "name": "i" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -4327,8 +4295,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -4518,8 +4485,7 @@ "identifierName": "f" }, "name": "f" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -4633,8 +4599,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "CallExpression", @@ -4740,8 +4705,7 @@ }, "name": "d" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -4839,8 +4803,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -4960,8 +4923,7 @@ "identifierName": "e" }, "name": "e" - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -5043,8 +5005,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "CallExpression", @@ -5187,8 +5148,7 @@ }, "name": "e" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -5270,8 +5230,7 @@ }, "identifierName": "a" }, - "name": "a", - "leadingComments": null + "name": "a" }, "consequent": { "type": "ArrowFunctionExpression", @@ -5421,8 +5380,7 @@ }, "name": "f" } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -5521,8 +5479,7 @@ }, "identifierName": "icecream" }, - "name": "icecream", - "leadingComments": null + "name": "icecream" }, "init": { "type": "ConditionalExpression", @@ -5968,8 +5925,7 @@ ] } } - }, - "leadingComments": null + } } ], "kind": "let", diff --git a/packages/babylon/test/fixtures/flow/type-generics/async-arrow-like/output.json b/packages/babylon/test/fixtures/flow/type-generics/async-arrow-like/output.json index 5b1aa319f9..ba4ecc83b5 100644 --- a/packages/babylon/test/fixtures/flow/type-generics/async-arrow-like/output.json +++ b/packages/babylon/test/fixtures/flow/type-generics/async-arrow-like/output.json @@ -316,8 +316,7 @@ }, "identifierName": "async" }, - "name": "async", - "leadingComments": null + "name": "async" }, "operator": "<", "right": { @@ -369,8 +368,7 @@ }, "name": "U" } - }, - "leadingComments": null + } }, "operator": ">", "right": { @@ -456,8 +454,7 @@ "parenthesized": true, "parenStart": 149 } - }, - "leadingComments": null + } }, "typeAnnotation": { "type": "TypeAnnotation", @@ -576,7 +573,6 @@ "typeParameters": null } }, - "leadingComments": null, "extra": { "parenthesized": true, "parenStart": 135 diff --git a/packages/babylon/test/fixtures/jsx/basic/10/output.json b/packages/babylon/test/fixtures/jsx/basic/10/output.json index 43d8c1ce23..7968812967 100644 --- a/packages/babylon/test/fixtures/jsx/basic/10/output.json +++ b/packages/babylon/test/fixtures/jsx/basic/10/output.json @@ -149,7 +149,6 @@ "column": 27 } }, - "leadingComments": null, "innerComments": [ { "type": "CommentBlock", diff --git a/packages/babylon/test/fixtures/jsx/basic/fragment-5/output.json b/packages/babylon/test/fixtures/jsx/basic/fragment-5/output.json index a303606313..f2cc422343 100644 --- a/packages/babylon/test/fixtures/jsx/basic/fragment-5/output.json +++ b/packages/babylon/test/fixtures/jsx/basic/fragment-5/output.json @@ -70,7 +70,6 @@ "column": 1 } }, - "leadingComments": null, "innerComments": [ { "type": "CommentLine", diff --git a/packages/babylon/test/fixtures/typescript/arrow-function/generic-tsx/output.json b/packages/babylon/test/fixtures/typescript/arrow-function/generic-tsx/output.json index 2240eb71da..80ffb23be7 100644 --- a/packages/babylon/test/fixtures/typescript/arrow-function/generic-tsx/output.json +++ b/packages/babylon/test/fixtures/typescript/arrow-function/generic-tsx/output.json @@ -218,11 +218,9 @@ "column": 2 } }, - "name": "T", - "leadingComments": null + "name": "T" } - ], - "leadingComments": null + ] } }, "leadingComments": [ diff --git a/packages/babylon/test/fixtures/typescript/cast/as/output.json b/packages/babylon/test/fixtures/typescript/cast/as/output.json index 89db7218dd..2582d6e627 100644 --- a/packages/babylon/test/fixtures/typescript/cast/as/output.json +++ b/packages/babylon/test/fixtures/typescript/cast/as/output.json @@ -263,8 +263,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "operator": "===", "right": { @@ -316,8 +315,7 @@ } } } - }, - "leadingComments": null + } }, "leadingComments": [ { @@ -413,8 +411,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "typeAnnotation": { "type": "TSAnyKeyword", @@ -430,8 +427,7 @@ "column": 8 } } - }, - "leadingComments": null + } }, "typeAnnotation": { "type": "TSTypeReference", @@ -464,8 +460,7 @@ }, "name": "T" } - }, - "leadingComments": null + } }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/typescript/class/abstract-false-positive/output.json b/packages/babylon/test/fixtures/typescript/class/abstract-false-positive/output.json index 087b254519..423d860e98 100644 --- a/packages/babylon/test/fixtures/typescript/class/abstract-false-positive/output.json +++ b/packages/babylon/test/fixtures/typescript/class/abstract-false-positive/output.json @@ -57,8 +57,7 @@ }, "identifierName": "abstract" }, - "name": "abstract", - "leadingComments": null + "name": "abstract" }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/typescript/class/abstract/output.json b/packages/babylon/test/fixtures/typescript/class/abstract/output.json index 081ab1355e..c79901a7db 100644 --- a/packages/babylon/test/fixtures/typescript/class/abstract/output.json +++ b/packages/babylon/test/fixtures/typescript/class/abstract/output.json @@ -192,11 +192,8 @@ "column": 26 } }, - "body": [], - "leadingComments": null, - "trailingComments": null - }, - "trailingComments": null + "body": [] + } }, "trailingComments": [ { @@ -261,10 +258,8 @@ "column": 33 } }, - "body": [], - "leadingComments": null + "body": [] }, - "leadingComments": null, "abstract": true }, "leadingComments": [ @@ -346,11 +341,8 @@ "column": 35 } }, - "body": [], - "leadingComments": null, - "trailingComments": null + "body": [] }, - "trailingComments": null, "abstract": true }, "trailingComments": [ diff --git a/packages/babylon/test/fixtures/typescript/class/parameter-properties/output.json b/packages/babylon/test/fixtures/typescript/class/parameter-properties/output.json index 4f0f32b462..75a3e5195f 100644 --- a/packages/babylon/test/fixtures/typescript/class/parameter-properties/output.json +++ b/packages/babylon/test/fixtures/typescript/class/parameter-properties/output.json @@ -385,8 +385,7 @@ }, "identifierName": "x" }, - "name": "x", - "leadingComments": null + "name": "x" }, "right": { "type": "NumericLiteral", @@ -407,8 +406,7 @@ "raw": "0" }, "value": 0 - }, - "leadingComments": null + } }, "leadingComments": [ { diff --git a/packages/babylon/test/fixtures/typescript/interface/export/output.json b/packages/babylon/test/fixtures/typescript/interface/export/output.json index 98373c9abf..20ba714aab 100644 --- a/packages/babylon/test/fixtures/typescript/interface/export/output.json +++ b/packages/babylon/test/fixtures/typescript/interface/export/output.json @@ -89,11 +89,8 @@ "column": 21 } }, - "body": [], - "leadingComments": null, - "trailingComments": null - }, - "trailingComments": null + "body": [] + } }, "trailingComments": [ { diff --git a/packages/babylon/test/fixtures/typescript/tsx/brace-is-block/output.json b/packages/babylon/test/fixtures/typescript/tsx/brace-is-block/output.json index 3031876fda..2d0b405cbc 100644 --- a/packages/babylon/test/fixtures/typescript/tsx/brace-is-block/output.json +++ b/packages/babylon/test/fixtures/typescript/tsx/brace-is-block/output.json @@ -57,8 +57,7 @@ }, "identifierName": "C" }, - "name": "C", - "leadingComments": null + "name": "C" }, "superClass": { "type": "Identifier", diff --git a/packages/babylon/test/fixtures/typescript/type-alias/export/output.json b/packages/babylon/test/fixtures/typescript/type-alias/export/output.json index 503ea72ce1..1bdcd10858 100644 --- a/packages/babylon/test/fixtures/typescript/type-alias/export/output.json +++ b/packages/babylon/test/fixtures/typescript/type-alias/export/output.json @@ -89,8 +89,7 @@ "column": 22 } } - }, - "trailingComments": null + } }, "trailingComments": [ { diff --git a/scripts/generators/flow.js b/scripts/generators/flow.js index e13839143d..b40aa2f2b2 100644 --- a/scripts/generators/flow.js +++ b/scripts/generators/flow.js @@ -36,9 +36,9 @@ declare class ${NODE_PREFIX}SourceLocation { } declare class ${NODE_PREFIX} { - leadingComments: ?Array<${NODE_PREFIX}Comment>; - innerComments: ?Array<${NODE_PREFIX}Comment>; - trailingComments: ?Array<${NODE_PREFIX}Comment>; + leadingComments?: Array<${NODE_PREFIX}Comment>; + innerComments?: Array<${NODE_PREFIX}Comment>; + trailingComments?: Array<${NODE_PREFIX}Comment>; start: ?number; end: ?number; loc: ?${NODE_PREFIX}SourceLocation;