小编Ste*_*Wan的帖子

在打字稿2.3.1中传播tsx中的反应道具

我有一些代码用于在typescript 2.2中编译好,但在2.3.1中失败:

class Component<T extends object> extends React.Component<T, {}> {
  render() { return <div { ...this.props }></div>; }
}
Run Code Online (Sandbox Code Playgroud)

我现在得到:

ERROR in ./file.tsx
(34,17): error TS2698: Spread types may only be created from object types.
Run Code Online (Sandbox Code Playgroud)

我怀疑这是由PR(在编写时未合并)修复的,但与此同时,有没有办法解决这个问题?

typescript

5
推荐指数
1
解决办法
753
查看次数

标签 统计

typescript ×1