[regression] Don't validate file.comments in @babel/types (#11752)

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
This commit is contained in:
Nicolò Ribaudo 2020-06-29 23:23:36 +02:00 committed by GitHub
parent 1dd94e813e
commit 5743ad3923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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: {

View File

@ -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();
});
});