Skip to content
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

Support type arguments in TSX #1860

Merged
merged 1 commit into from
Aug 27, 2022
Merged

Conversation

tancnle
Copy link
Collaborator

@tancnle tancnle commented Aug 18, 2022

Add support for type arguments in TSX lexer

Screen Shot 2022-08-26 at 11 50 48 pm

Fixes #1833

@tancnle
Copy link
Collaborator Author

tancnle commented Aug 19, 2022

👋🏼 @intgr Could you help to validate if this addresses the reported issue? 🙏🏼

@intgr
Copy link

intgr commented Aug 23, 2022

It would be hard for me to validate this. I noticed the issue in GitLab syntax highlighting, I don't use the Rouge library directly.

I can provide some more complicated test cases though:

const render = () => (
  <>
    <MyComponent<Type1, Type2> attr={value} foo="bar" />
    <MyComponent<Omit<Type, 'field'>> attr={value} foo="bar" />
    <MyComponent<{field: string}> attr={value} foo="bar" />
    <MyComponent<{field1: Omit<Type1, 'field2'>}, Type2> attr={value} foo="bar" />
  </>
);

@intgr
Copy link

intgr commented Aug 23, 2022

The screenshot you provided looks a bit weird.

image

The <> characters around Type have different colors (bright cyan and white). I would expect matching angle brackets to be the same color.

Edit: Oh, it's the same with <> characters in the tag.

@tancnle tancnle force-pushed the fix.type-args-tsx branch from 9510f6f to 1c851f3 Compare August 26, 2022 13:50
@tancnle
Copy link
Collaborator Author

tancnle commented Aug 26, 2022

The screenshot you provided looks a bit weird.

@intgr Great catch 💯 The original mixin was incorrect as it does not render the content after the < correctly. I have updated the code and added your suggested test cases. Please let me know what you think 🙏🏼

@intgr
Copy link

intgr commented Aug 26, 2022

Thanks for the quick response, looks perfect to me.

@tancnle tancnle force-pushed the fix.type-args-tsx branch 2 times, most recently from 86b79a8 to 9b0a0ca Compare August 27, 2022 07:02
@tancnle
Copy link
Collaborator Author

tancnle commented Aug 27, 2022

@intgr Heads up, I have split the addition of Typescript utility types to a separate PR and keep this just focusing on the type arguments support.

@tancnle tancnle merged commit 2ee9bf4 into rouge-ruby:master Aug 27, 2022
@tancnle tancnle deleted the fix.type-args-tsx branch August 27, 2022 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSX: Type args to generic components not recognized
2 participants