Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use safer and more reliable approach to cast Directive to ExpressionS…
…tatement
- Loading branch information
Showing
3 changed files
with
84 additions
and
31 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
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/estree/directives/interleaved-comments/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,4 @@ | ||
// 1; | ||
"use strict"; | ||
// 2; | ||
"use strict"; |
67 changes: 67 additions & 0 deletions
67
packages/babel-parser/test/fixtures/estree/directives/interleaved-comments/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,67 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":13}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":13}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":6,"end":19,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":13}}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 2;", | ||
"start":20,"end":25,"loc":{"start":{"line":3,"column":0,"index":20},"end":{"line":3,"column":5,"index":25}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 1;", | ||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}} | ||
} | ||
], | ||
"directive": "use strict", | ||
"expression": { | ||
"type": "Literal", | ||
"start":6,"end":18,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":12}}, | ||
"value": "use strict", | ||
"raw": "\"use strict\"" | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":26,"end":39,"loc":{"start":{"line":4,"column":0},"end":{"line":4,"column":13}}, | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 2;", | ||
"start":20,"end":25,"loc":{"start":{"line":3,"column":0,"index":20},"end":{"line":3,"column":5,"index":25}} | ||
} | ||
], | ||
"directive": "use strict", | ||
"expression": { | ||
"type": "Literal", | ||
"start":26,"end":38,"loc":{"start":{"line":4,"column":0},"end":{"line":4,"column":12}}, | ||
"value": "use strict", | ||
"raw": "\"use strict\"" | ||
} | ||
} | ||
] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " 1;", | ||
"start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}} | ||
}, | ||
{ | ||
"type": "CommentLine", | ||
"value": " 2;", | ||
"start":20,"end":25,"loc":{"start":{"line":3,"column":0,"index":20},"end":{"line":3,"column":5,"index":25}} | ||
} | ||
] | ||
} |