VS marks as error the syntax for a fragment

2
return <>
        <NavItem>
            <NavLink href={'/app/logout?returnUrl=${returnUrl}'}>Log out</NavLink>
        </NavItem>
</>

I have the previous code fragment inside a tsx file, in a folder in visual studio. He himself recognizes this kind of files (he gave them the icon) and I even have intellisense for the classes and methods.

However, it does not recognize the fragment as such, and throws an error in the IDE. However, the code compiles and runs without problems when doing npm start.

Therefore, it is a problem of the IDE

Doing

return <React.Fragment>
        <NavItem>
            <NavLink href={'/app/logout?returnUrl=${returnUrl}'}>Log out</NavLink>
        </NavItem>
</React.Fragment>

It does not throw error in the IDE. The question is, how do I tell my IDE that this code is right? (or is it a VS bug?)

    
asked by gbianchi 20.04.2018 в 19:45
source

1 answer

1

This problem occurs because the SDK for typescript is not embedded in the Visual Studio installation, and must be installed separately. By default, a package previous to version 2.5 of Ts is installed, which did not contain as valid the <> tag.

To solve this problem, you must download the microsoft page the last package and install it. When restarting Visual Studio, the problem will be solved.

    
answered by 28.04.2018 / 22:04
source