sucrase icon indicating copy to clipboard operation
sucrase copied to clipboard

Destructuring in named export from a function call is transpiled incorrectly

Open janmeier opened this issue 1 year ago • 0 comments

Suppose I have a function that returns an object. I call the function, and destructure the returned object, to export some of the properties:

https://sucrase.io/#compressedCode=H4sIAFEXCWcAA02OQQrDMAwE73rF3pJAX1DoMQ9xXKUNpFKRZVJa%2FPc47iW6LezMKqokxxS%2BuGHOEn1RQT%2FgB0I9Y88mNU3BrnDLjEKFKDZsVj1hB9Ugf5puEN4wmqn13dFbEmJYV753FwR75BeLp6G6%2BPNWc%2FyNbQilWutLtAMzFIeLnQAAAA%3D%3D

The destructuring is wrapped in a parenthesis, but it should be prefixed with a semicolon, otherwise we end up calling the statement on the previous line

With sucrase I get an error foo is called (foo is the function on the previous line), with babel and tsc I don't

janmeier avatar Oct 11 '24 12:10 janmeier