关于react.js:TypeScript-Error-2304-Cannot-find-name-div-CRA-TS-Template

3次阅读

共计 276 个字符,预计需要花费 1 分钟才能阅读完成。

背景

应用 react 官网文档上的命令 npx create-react-app my-app --template typescript 创立个一个 ts 我的项目,关上后发现 index.tsxApp.tsx 文件有报错。原来是 vscode workspace 中的 ts 版本 和 我的项目中的 ts 版本不统一 所致。

  1. 版本
   "react": "^17.0.2",
   "typescript": "^4.5.5",
  1. 报错如下

  1. 解决

vscode -> 设置 -> 工作区,关上 setting.json,增加:

{"typescript.tsdk": "./node_modules/typescript/lib"}
正文完
 0