Skip to content

Bug: Shows error when jsx is react-jsx in tsconfig instead of react #20391

Closed

Description

@bineetNaidu

React version: 17.0.1

Steps To Reproduce

  1. npx create-react-app [your project name] --template typescript
  2. set target in tsconfig to ESNEXT

The current behavior

In VS Code their is many syntax error highlight and it says "Cannot use JSX unless the '--jsx' flag is provided.ts(17004)"

The expected behavior

It Should be normal like other version of react usage

Screenshots

tsconfig.json
Screenshot from 2020-12-07 17-09-22
index.tsx
Screenshot from 2020-12-07 17-10-37

Activity

  1. eps1lon commented on Dec 7, 2020

    @eps1lon
    Collaborator

    Thanks for the report.

    VSCode is, by default, using their own version of TypeScript. In your case: 4.0.3. However, "jsx": "react-jsx" is only supported starting with TypeScript 4.1. You can change the version though to the version used in your package:
    react-jsx-vscode

    how to find the current version of TypeScript used in VSCode ![101346839-2a987980-38af-11eb-9ebd-e63388f52df1](https://user-images.githubusercontent.com/12292047/101359911-311df580-389d-11eb-89f8-91b288731653.png)
  2. bineetNaidu commented on Dec 7, 2020

    @bineetNaidu
    Author

    Thanks for letting me to know, I thought that it was a bug 😅 😅 😅

  3. Cidrax commented on Jan 31, 2021

    @Cidrax

    Im using WebStorms and have the same issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions