Skip to content

Commit

Permalink
[regression] Don't validate file.comments in @babel/types (#11752)
Browse files Browse the repository at this point in the history
Co-authored-by: Hu谩ng J霉nli脿ng <jlhwung@gmail.com>
  • Loading branch information
nicolo-ribaudo and JLHwung committed Jun 29, 2020
1 parent 1dd94e8 commit 5743ad3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/babel-types/src/definitions/core.js
Expand Up @@ -280,7 +280,11 @@ defineType("File", {
validate: assertNodeType("Program"),
},
comments: {
validate: assertEach(assertNodeType("Comment")),
validate: !process.env.BABEL_TYPES_8_BREAKING
? Object.assign(() => {}, {
each: { oneOfNodeTypes: ["CommentBlock", "CommentLine"] },
})
: assertEach(assertNodeType("CommentBlock", "CommentLine")),
optional: true,
},
tokens: {
Expand Down
9 changes: 9 additions & 0 deletions packages/babel-types/test/regressions.js
@@ -0,0 +1,9 @@
import * as t from "../lib";

describe("regressions", () => {
it("jest .toMatchInlineSnapshot used 'Line' for comments", () => {
expect(() => {
t.file(t.program([]), [{ type: "Line" }]);
}).not.toThrow();
});
});

0 comments on commit 5743ad3

Please sign in to comment.