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

Shorthand JSX Fragments breaks syntax highlighting #368

Closed
Svish opened this issue Feb 28, 2019 · 21 comments
Closed

Shorthand JSX Fragments breaks syntax highlighting #368

Svish opened this issue Feb 28, 2019 · 21 comments

Comments

@Svish
Copy link

Svish commented Feb 28, 2019

The shorthand version of writing react jsx fragments breaks all the syntax highlighting after its closing tag:

capture

😟

@simonpai
Copy link

simonpai commented Mar 9, 2019

The last commit of this project was in May 2018.
You can try either Naomi or JS Custom as an alternative.

@fedecarg
Copy link

For feature reference, the extension that break JSX in VSCode is: Babel ES6/ES7. It's promoted in the Marketplace as the oficial Babel extension, but it's not.

dzannotti/vscode-babel#23

@scott-ln
Copy link

scott-ln commented Aug 9, 2019

The bug is triggered by the opening tag; changing <> to <x> will restore syntax highlighting to the code outside the fragment.

@IanIsFluent
Copy link

IanIsFluent commented Oct 18, 2019

The bug is triggered by the opening tag; changing <> to <x> will restore syntax highlighting to the code outside the fragment.

But. That's invalid? How is that a solution!?

Expected corresponding JSX closing tag for 'x'.ts(17002)
Identifier expected.ts(1003)

@scott-ln
Copy link

No no, you misunderstand! I was just describing exactly how to trigger the bug.

@IanIsFluent
Copy link

No no, you misunderstand! I was just describing exactly how to trigger the bug.

Sorry! I think the party popper reactions suggested this was a solution, not so much the wording of your comment! 😆

@scott-ln
Copy link

Haha! Yeah I was pretty surprised to come back here and see those too. After writing that comment I actually ended up switching to Naomi from Simon's suggestion above, it's great.

@icharge
Copy link

icharge commented Dec 19, 2019

image
Set TypeScript React for *.js or *.jsx it worked

@icharge
Copy link

icharge commented Jan 7, 2020

image
Set TypeScript React for *.js or *.jsx it worked

That way will produce a lot of warnings about typing. So better way is adding comment slashes after </>

Before:

image

After:

image

Hope this will help.

@Thom1729
Copy link
Contributor

This should be fixed in v10.0.0-beta.1. See #379 for more information on the new release. Please report any problems with v10 in a new issue.

@IPWright83
Copy link

@Thom1729 how do you go about installing a beta package to test this?

@Thom1729
Copy link
Contributor

You have to tell Package Control to install prerelease versions of Babel:

  1. Run Preferences: Package Control Settings — User from the command palette to open your Package Control settings.
  2. Add install_prereleases: ['Babel']. (If you already had install_prereleases, add Babel to the list.)
  3. Run Package Control: Upgrade Package and select Babel, or just wait for the next time Package Control checks for new package versions.

@jrandyanderson
Copy link

@Thom1729 This worked for me! Thank you.

@MKorostoff
Copy link

@Thom1729 this worked for me! thanks!

@williampratt
Copy link

Sorry for commenting on a closed issue, but any time frame for a new release to include fixes like this so we don't have to always update to pre-release? Thanks for the solution though @Thom1729!

@sshadmand
Copy link

sshadmand commented Jul 14, 2020

I believe I followed the steps above but still getting errors with "<>" shorthand in Sublime 3.

Screen Shot 2020-07-13 at 6 09 46 PM

Screen Shot 2020-07-13 at 6 09 32 PM

Note: I've also restarted Sublime 3 and ran an "Upgrade.. All Packages" as well
Screen Shot 2020-07-13 at 6 13 27 PM

@williampratt
Copy link

williampratt commented Jul 14, 2020

@sshadmand, you need to place it in the package control setting file, not Babel's settings.
Go to Preferences -> Package Settings -> Package Control -> Settings - User and add the following:

"install_prereleases": [ "Babel" ],

Then Tools -> Command Palette -> Package Control: Upgrade Package

That should do it!

@sshadmand
Copy link

sshadmand commented Jul 15, 2020

Followed the steps @williampratt. Seems to still throw an error 🤷‍♂️

Screen Shot 2020-07-14 at 6 05 51 PM

Screen Shot 2020-07-14 at 6 06 00 PM

Screen Shot 2020-07-14 at 6 12 39 PM

@williampratt
Copy link

What version do you see when you run Package Control: List Packages? I am not seeing the issue in v 10.0.0-beta.2

babel

@woonketwong
Copy link

The step works for me.

@larrymoe
Copy link

Worked for me. Thanks @williampratt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests