Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/babel-types/src/definitions/core.js
Expand Up @@ -280,7 +280,9 @@ defineType("File", {
validate: assertNodeType("Program"),
},
comments: {
validate: assertEach(assertNodeType("Comment")),
validate: !process.env.BABEL_TYPES_8_BREAKING
? Object.assign(() => {}, { each: { type: "Comment" } })
: assertEach(assertNodeType("Comment")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing, I noticed, when looking into referred issue:

assertNodeType("Comment") results in correct typescript types, but actual check is not correct instead it should be 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 usef 'Line' for comments", () => {
nicolo-ribaudo marked this conversation as resolved.
Show resolved Hide resolved
expect(() => {
t.file(t.program([]), [{ type: "Line" }]);
}).not.toThrow();
});
});