-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Syntax error for TypeScript generics #425
Labels
Comments
alecthomas
pushed a commit
that referenced
this issue
Sep 21, 2024
#425 shows that generics are not correctly identified in general, but they are rather being treated as JSX elements. I proposed a simple solution in the comments by adding a space between `<` and the word next to it, but I believe most people will either not find the solution or some of them will find it rather unappealing. For this reason, I made the JSX rules recursive and added a `","` `Punctuation` token inside so that there can be a number of generics used, as well as allowing nested generics. While I am not really fond of this hack, given that generics are already treated as JSX elements, I think this is a fair and easy enough solution for most cases. #### Before <img width="359" alt="Screenshot 2024-09-20 at 9 28 05 PM" src="https://github.com/user-attachments/assets/b03c2c8a-3278-438b-8803-00eb62cc4a17"> #### With spacing solution <img width="392" alt="Screenshot 2024-09-20 at 9 30 13 PM" src="https://github.com/user-attachments/assets/89289476-c92a-41df-b893-5ab289fa96aa"> #### With recursive JSX and `","` `Punctuation` token <img width="362" alt="Screenshot 2024-09-20 at 9 55 11 PM" src="https://github.com/user-attachments/assets/d77d892e-667d-4fb4-93cf-8227d5bd4b17">
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Chroma seems to not understand TypeScript generics with multiple template arguments and/or template arguments using a generic type too.
Consider the following TypeScript code:
Chroma v0.8.2 and Hugo v0.78.2 render the code with a comma (
,
) characters highlighted in red - perhaps suggesting an error?To Reproduce
Save the following text to
bug.ts
.Run chroma as follows:
Open the produced HTML file in a Chromium-based browers. You should see the same output as on my screenshot posted above.
The text was updated successfully, but these errors were encountered: