Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing of block comments nested in flow comments (#15062)
* Fix parsing of comments inside flow comments * Fix parsing of block comments nested in flow comments
- Loading branch information
1 parent
cbef14b
commit 73c9aef
Showing
4 changed files
with
132 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/flow/comment/14-code-after-nested-comment/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let data /*: /* comment *-/T */; | ||
|
||
const c = (data/*: /* this is an object *-/ Object */) => {}; |
120 changes: 120 additions & 0 deletions
120
packages/babel-parser/test/fixtures/flow/comment/14-code-after-nested-comment/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":95,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":61,"index":95}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":95,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":61,"index":95}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":32,"index":32}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":28,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":28,"index":28}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":28,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":28,"index":28},"identifierName":"data"}, | ||
"name": "data", | ||
"typeAnnotation": { | ||
"type": "TypeAnnotation", | ||
"start":11,"end":28,"loc":{"start":{"line":1,"column":11,"index":11},"end":{"line":1,"column":28,"index":28}}, | ||
"typeAnnotation": { | ||
"type": "GenericTypeAnnotation", | ||
"start":27,"end":28,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":28,"index":28}}, | ||
"typeParameters": null, | ||
"id": { | ||
"type": "Identifier", | ||
"start":27,"end":28,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":28,"index":28},"identifierName":"T"}, | ||
"name": "T" | ||
}, | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " comment ", | ||
"start":13,"end":27,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":27,"index":27}} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
}, | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":34,"end":95,"loc":{"start":{"line":3,"column":0,"index":34},"end":{"line":3,"column":61,"index":95}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":40,"end":94,"loc":{"start":{"line":3,"column":6,"index":40},"end":{"line":3,"column":60,"index":94}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":40,"end":41,"loc":{"start":{"line":3,"column":6,"index":40},"end":{"line":3,"column":7,"index":41},"identifierName":"c"}, | ||
"name": "c" | ||
}, | ||
"init": { | ||
"type": "ArrowFunctionExpression", | ||
"start":44,"end":94,"loc":{"start":{"line":3,"column":10,"index":44},"end":{"line":3,"column":60,"index":94}}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"params": [ | ||
{ | ||
"type": "Identifier", | ||
"start":45,"end":84,"loc":{"start":{"line":3,"column":11,"index":45},"end":{"line":3,"column":50,"index":84},"identifierName":"data"}, | ||
"name": "data", | ||
"typeAnnotation": { | ||
"type": "TypeAnnotation", | ||
"start":51,"end":84,"loc":{"start":{"line":3,"column":17,"index":51},"end":{"line":3,"column":50,"index":84}}, | ||
"typeAnnotation": { | ||
"type": "GenericTypeAnnotation", | ||
"start":78,"end":84,"loc":{"start":{"line":3,"column":44,"index":78},"end":{"line":3,"column":50,"index":84}}, | ||
"typeParameters": null, | ||
"id": { | ||
"type": "Identifier", | ||
"start":78,"end":84,"loc":{"start":{"line":3,"column":44,"index":78},"end":{"line":3,"column":50,"index":84},"identifierName":"Object"}, | ||
"name": "Object" | ||
}, | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " this is an object ", | ||
"start":53,"end":77,"loc":{"start":{"line":3,"column":19,"index":53},"end":{"line":3,"column":43,"index":77}} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":92,"end":94,"loc":{"start":{"line":3,"column":58,"index":92},"end":{"line":3,"column":60,"index":94}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
} | ||
} | ||
], | ||
"kind": "const" | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " comment ", | ||
"start":13,"end":27,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":27,"index":27}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " this is an object ", | ||
"start":53,"end":77,"loc":{"start":{"line":3,"column":19,"index":53},"end":{"line":3,"column":43,"index":77}} | ||
} | ||
] | ||
} |