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

Don't treat /*/ as an entire block comment #430

Merged
merged 1 commit into from
Mar 4, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/parser/tokenizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export function skipSpace(): void {
case charCodes.slash:
switch (input.charCodeAt(state.pos + 1)) {
case charCodes.asterisk:
state.pos += 2;
skipBlockComment();
break;

Expand Down
24 changes: 24 additions & 0 deletions test/sucrase-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,4 +747,28 @@ describe("sucrase", () => {
it("handles a file with only an assignment", () => {
assertResult("a = 1", '"use strict";a = 1', {transforms: ["imports"]});
});

it("handles a standalone comment that looks like it could be a regex", () => {
assertResult(
`
/*/*/;
`,
`
/*/*/;
`,
{transforms: []},
);
});

it("handles a comment that looks like it could be a regex after a string", () => {
assertResult(
`
let thing = "sup" /*/*/;
`,
`
let thing = "sup" /*/*/;
`,
{transforms: []},
);
});
});