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

fix: Don't auto tag fragment if not in jsx #210

Merged

Conversation

akozlev
Copy link
Contributor

@akozlev akozlev commented Aug 14, 2024

Use treesitter to determine whether node is a jsx_opening_element and use this info to bail out if the user may be writing a generic parameter.

Solves issue mentioned in #202 (comment) where useState<> becomes useState<></> when the user is typing out a generic type argument in typescriptreact files.

A thing to note is that there is still an ambiguity in the grammar while typing:

// If the user types:
const foo = <T>
// It could be a generic function:
const foo = <T>() => { ... };
// Alternatively it could be a JSX element:
const foo = <T></T>;

But generic inline functions are less common than generic types and argument so this PR fixes most cases.

Use treesitter to determine whether node is a jsx_opening_element and
use this info to bail out if the user may be writing a generic
parameter.
@akozlev akozlev changed the title Fix dont auto tag fragment if not in jsx fix: Don't auto tag fragment if not in jsx Aug 14, 2024
@PriceHiller PriceHiller merged commit 0cb76ee into windwp:main Aug 15, 2024
0 of 2 checks passed
@PriceHiller
Copy link
Collaborator

Thanks for the PR 🙂!

The test failure is from an older issue that still needs to be fixed, not relevant to this PR.

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.

2 participants