tsconfig.json 配置 update `jsx: “react“` into `jsx: “react-jsx“`终端警告

使用 umiJS 时出现的终端警告:
WARN [WARN] update jsx: "react" into jsx: "react-jsx" to suport the new JSX transform in React 17 in tsconfig.json

在这里插入图片描述

解决方法:

确保 typescript 的依赖安装完成,随便打开一个提示错误的 .tsx 文件。

macOS 使用 command + shift + p,Windows 貌似是 ctrl + shift + p

然后输入 TypeScript ,不出意外的话你会看到 Select Typescript Version 选项。
选择 node_modules 下的那个版本(一般来说都会比较新)。

一般来说就没有问题了。
在这里插入图片描述

在这里插入图片描述
tsconfig.json 文件

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "jsx": "react-jsx",
    "esModuleInterop": true,
    "sourceMap": true,
    "baseUrl": "./",
    "strict": true,
    "paths": {
      "@/*": ["src/*"],
      "@@/*": ["src/.umi/*"]
    },
    "allowSyntheticDefaultImports": true
  },
  "include": [
    "mock/**/*",
    "src/**/*",
    "config/**/*",
    ".umirc.ts",
    "typings.d.ts"
  ],
  "exclude": [
    "node_modules",
    "lib",
    "es",
    "dist",
    "typings",
    "**/__test__",
    "test",
    "docs",
    "tests"
  ]
}

在这里插入图片描述

参考:
🐛[BUG] update jsx: "react" into jsx: "react-jsx" to suport the new JSX transform in React 17 in tsconfig.json #7698

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值