小编Den*_*bon的帖子

使用“react-jsx”作为带有 create-react-app 的 jsx 值的 Visual Studio Code 问题

我正在努力解决 VSCode 中的“错误”:

Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'
Run Code Online (Sandbox Code Playgroud)

因此,当value 似乎有效时,react-scripts (create-react-app) 会自动将jsxkey设置为react-jsxvalue react

实际上,代码运行良好并显示了我想要的页面,但是 IDE 将所有内容都强调为错误,并说:

Cannot use JSX unless the '--jsx' flag is provided.
Run Code Online (Sandbox Code Playgroud)

这是我的 tsconfig.json :

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
} …
Run Code Online (Sandbox Code Playgroud)

jsx typescript tsconfig visual-studio-code create-react-app

73
推荐指数
3
解决办法
2万
查看次数