Skip to content

Unnecessary braces when autocompleting JSX props #7341

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

Open
cknitt opened this issue Mar 13, 2025 · 4 comments
Open

Unnecessary braces when autocompleting JSX props #7341

cknitt opened this issue Mar 13, 2025 · 4 comments
Labels
editor Everything concerning the analysis binary

Comments

@cknitt
Copy link
Member

cknitt commented Mar 13, 2025

Example:

type myVariant = AAAAA | BBBBB

module MyComponent = {
  @react.component
  let make = (~x: myVariant) => (x :> string)->React.string
}

<MyComponent x=

Autcomplete correctly suggests AAAAA and BBBBB. When I select AAAAA, I get

<MyComponent x={AAAAA}

The braces are unnecessary here, so I usually remove them again manually to get

<MyComponent x=AAAAA
@cknitt cknitt added the editor Everything concerning the analysis binary label Mar 13, 2025
@shulhi
Copy link
Member

shulhi commented Apr 15, 2025

I actually prefer having curly braces, mostly because of how it is in React JS.

@zth
Copy link
Collaborator

zth commented Apr 15, 2025

Yeah this is actually intentional, and it's to be uniform (can always have braces, can not always not have braces). Plus, make it easier to change the expression. If you add a pipe to AAAAA in the example above you'll need to wrap with braces anyway or you get a somewhat non obvious syntax error.

@cknitt
Copy link
Member Author

cknitt commented Apr 15, 2025

In my perception, this just adds visual noise.

But if we want to standardize on having the braces because that's how it is in React JS, then maybe

<MyComponent x=AAAAA

actually should be reformatted to

<MyComponent x={AAAAA}

?

@shulhi
Copy link
Member

shulhi commented Apr 26, 2025

In my perception, this just adds visual noise.

But if we want to standardize on having the braces because that's how it is in React JS, then maybe

<MyComponent x=AAAAA
actually should be reformatted to

<MyComponent x={AAAAA}
?

I can add this to the formatter to always add braces if we decided that we should do it this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Everything concerning the analysis binary
Projects
None yet
Development

No branches or pull requests

3 participants