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

fix: Certain comments cause generator exceptions #14810

Merged
merged 2 commits into from Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions packages/babel-generator/src/printer.ts
Expand Up @@ -805,6 +805,8 @@ class Printer {
} else if (!this._noLineTerminator) {
val = `//${comment.value}\n`;
maybeNewline = true;
} else {
val = `/*${comment.value}*/`;
Copy link
Member

Choose a reason for hiding this comment

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

This case is for when we had a line comment but we cannot have a line terminator? When can it happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in the associated issue. I also added to the test.
You said that and it reminded me that it doesn't contain newlines!😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Testing doesn't seem to reflect this.😕

Tested on my local.

const test = (): {
  /* test*/foo: string;
} => {
  return {
    foo: "bar"
  };
};

export default test;

Copy link
Member Author

Choose a reason for hiding this comment

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

#14758
#14762

Oh no, after a long time, I finally found the reason.
Only the first pr was published, and the second was not.

So this test is useless, we need to find another one.

By the way, can you release a new version of jest-light-runner?
Filtering of tests can be helpful in debugging generators and parsers.

}

// Avoid creating //* comments
Expand Down
@@ -0,0 +1,10 @@
const test = (): {
// test
foo: string;
} => {
return {
foo: "bar"
};
};

export default test;
@@ -0,0 +1 @@
{ "plugins": ["typescript"] }
@@ -0,0 +1,10 @@
const test = (): {
// test
foo: string;
} => {
return {
foo: "bar"
};
};

export default test;