Certain syntax errors have poor position recovery
nmain opened this issue · 0 comments
nmain commented
With the following Javascript code:
(() => {
<div>This div has no end
})();
Babel gives an expected error message:
/sample.js: Unterminated JSX contents. (2:9)
1 | (() => {
> 2 | <div>This div has no end
| ^
3 | })();
But Sucrase is less helpful:
Error transforming sample.js: Unexpected token, expected "," (1:5)
An extra comma at line 1 col 5? I don't quite understand that.
If a non-arrow function is used, Sucrase does give a good result:
(function() {
<div>This div has no end
}).call(this);
Error transforming sample.js: Unterminated JSX contents (2:10)
This isn't an important bug to me, as bad syntax is bad syntax. But I'm reporting this because it did work as I'd expect on Sucrase 3.16, so maybe it's something that can be easily fixed.