JSX element implicitly has type ‘any‘ because
Intro今天使用VSCode打开一个用React开发的前端项目,报错如下:JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements'在搜索过程中还看到相似的两个错误:error TS2602: JSX element implicitly has type 'any' because the
Intro
今天使用VSCode
打开一个用React
开发的前端项目,报错如下:
JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements'
在搜索过程中还看到相似的两个错误:
error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist
error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.
原因
没有安装@types/react
或者说在当前项目的 node_modules
目录下没有找到该依赖。
解决
检查package.json
。看有没有@types/react
这项依赖。
如果没有,npm i -D @types/react
或npm install --save-dev @types/react
。
如果有(我的就是这种情况),则是因为我们只是用VSCode打开了该前端项目,但并未安装项目依赖导致。安装项目依赖即可:npm i
Links
更多推荐
所有评论(0)