-
Notifications
You must be signed in to change notification settings - Fork 16
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
Nested generics produce a syntax error if not parenthesized #194
Comments
Thanks for your report this is like to be a swc bug. cc @kdy1 |
cc @magic-akari Can you take a look? |
I found some issues in SWC that are related. There are even some linked PRs, but the issue is still present in the version used by Node.
SWC has a bot to auto-close issues which I find very user hostile, so for now I'll leave the issue here. The first issue there would be the perfect one to discuss this, but the fact that it was auto-closed before being fully resolved sends mixed signals. |
Thank you for the heads-up! I’ve noted the issue and will prioritize fixing it as soon as possible. |
**Related issue:** - nodejs/amaro#194
Thank you for the quick PR. I'll keep checking as new Node versions get released and I'll close the ticket when the fix is released on Node current. |
I have some complex TypeScript with a generic type argument which is itself generic. The TypeScript compiler supports it for many years (at least TS 3.x), and I verified that it works with the
--erasableSyntaxOnly
flag from TS 5.8.I would expect it to work with Node's builtin type stripper then, but I get an error. Here is a reduced code sample exhibiting the error. I marked the line with the error:
Here is the error that I get with Node 23.9.0:
A workaround is to add parenthesis:
Since there's an available workaround, it's not a high priority for me; but I'm sharing it as it's a relatively unusual piece of code so I don't expect it to be fully tested. I'm reporting it since I found the issue with Node's type stripper, if it's not the right place please let me know where I should post.
It may also be that the syntax above is somehow ambiguous and won't be ever supported, but maybe the error could be clearer in this case.
EDIT
I also found that simply spacing the brackets works:
The issue is probably in tokenization between nested generics and bit-shift operators.
The text was updated successfully, but these errors were encountered: