TS2344:类型“keyof T”不满足约束“string”

1,使用场景:

react+antd+typescript

2,报错信息:

类型“keyof T”不满足约束“string”。
  不能将类型“string | number | symbol”分配给类型“string”。
    不能将类型“number”分配给类型“string”。

3,解决方式:

在tsconfig.json中添加:

"keyofStringsOnly": true

猜你喜欢

转载自blog.csdn.net/weixin_39496190/article/details/85158383
今日推荐