TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.
在使用typescript的时候,在vue或react、node中报以上错误,是JSX 元素隐式具有类型 "any",因为不存在全局类型 "JSX.Element"。
处理的办法有二种:
- 不使用严格的类型检查,即在 tsconfig.json 中设置 "strict": false
- 在 tsconfig.json中设置 "noImplicitThis": false
1 |
"noImplicitAny": false, // 是否在表达式和声明上有隐含的any类型时报错 |
tsconfig.json 的配置选项可查看官方文档