37

TypeScript Error 2304: Cannot find name 'div' - CRA TS Template

 2 years ago
source link: https://segmentfault.com/a/1190000041473578
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

TypeScript Error 2304: Cannot find name 'div' - CRA TS Template

发布于 51 分钟前

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

   "react": "^17.0.2",
   "typescript": "^4.5.5",

企业微信截图_16460472488336.png

企业微信截图_16460475176970.png

vscode -> 设置 -> 工作区,打开 setting.json, 添加:

{
   "typescript.tsdk": "./node_modules/typescript/lib"
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK