【问题标题】:NeoVim for TypeScript React development用于 TypeScript React 开发的 NeoVim
【发布时间】:2021-09-07 03:14:10
【问题描述】:

我是 vim 的新手。我只是想用 react 检查我的配置,因为我使用 typescript 和 react,所以我尝试创建一个简单的演示应用程序,所以我运行了 npx create-react-app demo --template typescript。 之后,我在目录中运行了nvim .,但是当我选择任何组件时,我得到了这个警告:

除非提供了 '--jsx' 标志,否则不能使用 JSX。 (修复)

即使在 tsconfig.json 文件中指定了

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"
  ]
}

我确实安装了一个 TS 插件,但我不知道为什么会发生这种情况

这是我到目前为止的 vim 配置 ez-config,我使用 :help nvim-from-vim 让 nvim 从文件中加载配置

【问题讨论】:

    标签: reactjs typescript neovim


    【解决方案1】:

    您遇到的问题是这一行 --> "jsx":"react-jsx",它必须更改为 "jsx":"react",但是,每次运行 npm 时它可能会覆盖它到“react-jsx”。你可以试试这个解决方案:https://stackoverflow.com/a/64969461/14944117

    【讨论】:

    • 谢谢,我从没想过这会是问题,因为 VS Code 可以使用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 2021-06-18
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    相关资源
    最近更新 更多