tdesign-react icon indicating copy to clipboard operation
tdesign-react copied to clipboard

[Radio] Argument of type 'RadioValue' is not assignable to parameter of type 'SetStateAction<string>'

Open NWYLZW opened this issue 2 years ago • 2 comments

重现链接

https://codesandbox.io/s/tdesign-react-demo-forked-hwf05v?file=/src/demo.tsx

重现步骤

使用 tsx typescript 会提示类型不匹配

期望结果

应该匹配到对应的类型

实际结果

0F2F5D46-C0FF-4904-A467-2D5799659BFF

Environment Info
相关版本 0.36.4
框架版本 / 基础库版本 React(16.13.1)
系统、浏览器 Chrome(103.0.5060.114)
Node版本

NWYLZW avatar Jul 15 '22 08:07 NWYLZW

可以这样处理,不会报错了

组件是什么类型,最好变量就是什么类型

我们缺少一个范型,用于指定 RadioValue 的具体类型,后面可以补一下

image

chaishi avatar Jul 16 '22 02:07 chaishi

可以这样处理,不会报错了

组件是什么类型,最好变量就是什么类型

我们缺少一个范型,用于指定 RadioValue 的具体类型,后面可以补一下

image

是,其实我倒是知道这样子修复 提出 issue 的目的其实是想要一个好一点的泛型支持

除了上面的修复方式,其实还有一种就是 onChange 的时候 String(value)

NWYLZW avatar Jul 16 '22 05:07 NWYLZW

这个 Issue 被标记为了过时 stale ,因为它已经持续 30 天没有任何活动了。删除 stale 标签或评论,否则将在 7 天内关闭。

github-actions[bot] avatar Aug 15 '22 05:08 github-actions[bot]

此 Issue 被自动关闭,因为它自被标记为过时 stale 以来已闲置 7 天。

github-actions[bot] avatar Aug 22 '22 05:08 github-actions[bot]