Skip to content

Create-react-app should create a jsconfig.json file by default #13663

Open
@dpschramm

Description

@dpschramm

Is your proposal related to a problem?

When creating a JS project, IDE's like VS Code won't provide import suggestions unless the checkJs compiler option is enabled. However, enabling this option causes VS Code to raise a number of issues with JSX in React JS files.

Version information:

  • VS Code Version: 1.92.2 (Universal)
  • Commit: fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
  • Date: 2024-08-14T17:29:30.058Z (3 wks ago)
  • Electron: 30.1.2
  • ElectronBuildId: 9870757
  • Chromium: 124.0.6367.243
  • Node.js: 20.14.0
  • V8: 12.4.254.20-electron.0
  • OS: Darwin arm64 23.5.0
  • React Scripts: 5.0.1

Describe the solution you'd like

Creating a jsconfig.json file within the project, with the following content enables import suggestions in VS Code, and avoids VS Code flagging errors due to JSX.

{
    "compilerOptions": {
        "checkJs": true,
        "jsx": "react-jsx"
    }
}

Describe alternatives you've considered

VS Code has a JS/TS › Implicit Project Config: Check JS setting, which is equivalent to checkJs, but this does not tell VS Code how to handle JSX in JS files, so a jsconfig.json file is still needed.

Additional context

Import suggestions are an important feature for modern IDEs, and having this work out of the box for a popular IDE like VS Code would improve the React developer experience, especially for new developers.

Example Stack Overflow question asking about this: https://stackoverflow.com/questions/77490192/why-am-i-getting-no-import-suggestions-in-my-react-project-in-vs-code/78946476#78946476

My understanding is TypeScript projects do have a tsconfig.json file created. It would be good to have parity for JS.

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