Closed akozlev closed 1 month ago
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 https://github.com/windwp/nvim-ts-autotag/pull/202#issuecomment-2254467345 where useState<> becomes useState<></> when the user is typing out a generic type argument in typescriptreact files.
useState<>
useState<></>
typescriptreact
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.
Thanks for the PR 🙂!
The test failure is from an older issue that still needs to be fixed, not relevant to this PR.
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 https://github.com/windwp/nvim-ts-autotag/pull/202#issuecomment-2254467345 where
useState<>
becomesuseState<></>
when the user is typing out a generic type argument intypescriptreact
files.A thing to note is that there is still an ambiguity in the grammar while typing:
But generic inline functions are less common than generic types and argument so this PR fixes most cases.