-
Notifications
You must be signed in to change notification settings - Fork 143
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
imported function call without leading semicolon #322
Comments
Thanks. JS is the worst... This seems hard, but there may be a nice fix with enough creativity. Generally the straightforward fix is to put a semicolon either after the Interestingly, this only happens because of the I probably won't have time to get to this really soon, but will take a closer look when I get a chance. Also happy to accept a PR for the |
I bet you could just run Prettier on the output. lol |
Prettier's too slow. 😛 |
I was curious on details, so just to add some actual numbers to my off-the-cuff statement, looks like Prettier is about as slow as Babel, at least in simple cases:
|
Which modules are related to this specific case? edit: I found this: sucrase/src/transformers/CJSImportTransformer.ts Lines 180 to 196 in 9fdabab
Are there more, or is that it? |
We should transpile to |
@aleclarson Yep, that's the main place where the replacement happens. There's also one similar case in
Good point, in general I think that should work, but here's an example case that makes me worry: https://sucrase.io/#code=import%20a%20from%20'a'%3B%0Aimport%20b%20from%20'b'%3B%0A(a%20%2B%20b)() Right now it's a benign false positive in Sucrase since For the The CI test suite runs on a bunch of open source projects ( Sounds like you're interested in taking this on? Happy to chat through it more either here or on Gitter. I was also still hoping to get to this at some point, and I have some free time coming up, so if you get stuck, I can take over. |
To clarify the Right now, the algorithm for replacing
If all of those are true, then we do the The thing I'm pondering is whether that Some example cases to think about: |
If we detect a right paren(s) before the left paren, then using If no right parens are detected, then using WDYT? |
Good point. I think I'd probably still prefer to keep the same strategy everywhere, so I think I'd prefer to do |
What does this comment mean?
|
(Oops, typo, it should be "just do the regular replacement".) I think it's referring to cases like this: export let x = 1;
x = 2; Without being careful, we might transform the second line to If you're reworking the code, not super-important to keep that line, I think it made more sense in the original context. |
Repro link
..becomes..
..which evaluates to
TypeError: [] is not a function
The text was updated successfully, but these errors were encountered: