-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TypeScript lexer to allow nested generics (#1002)
#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">
- Loading branch information
Showing
3 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters