最近,我将一个工作的JavaScript/React项目迁移到了类型记录。在任何地方,在React组件中,我使用的都是antd组件,代码不能进行类型检查。我有以下几件事:
import { Radio, Button } from 'antd';
...
<Radio.Group ...>
<Radio.Button ...>a button</Radio.Button>
</Radio.Group>..。我得到的类型错误如下:
TS2339: Property 'Group' does not exist on type 'ForwardRefExoticComponent<RadioProps & RefAttributes<unknown>>'.
TS2339: Property 'Button' does not exist on type 'ForwardRefExoticComponent<RadioProps & RefAttributes<unknown>>'antd型部分表示库已准备好打字稿,甚至表示不必使用npm i --D @types/antd。在显式安装和不安装@types/antd的情况下,我都试过了,但这似乎没有什么区别。
我正在使用:
发布于 2020-07-01 15:01:17
在我的moduleResolution的compilerOptions of my tsconfig.json中将"node"设置为"node"修复了这个问题。
https://stackoverflow.com/questions/62677671
复制相似问题