diff --git a/src/parser/tokenizer/index.ts b/src/parser/tokenizer/index.ts index 1346e236..9ba69b19 100644 --- a/src/parser/tokenizer/index.ts +++ b/src/parser/tokenizer/index.ts @@ -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; diff --git a/test/sucrase-test.ts b/test/sucrase-test.ts index e36eca1f..746dd60c 100644 --- a/test/sucrase-test.ts +++ b/test/sucrase-test.ts @@ -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: []}, + ); + }); });