diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 38948a63db..b909c13d39 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -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: { diff --git a/packages/babel-types/test/regressions.js b/packages/babel-types/test/regressions.js new file mode 100644 index 0000000000..04c345ba7e --- /dev/null +++ b/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(); + }); +});