0
打字稿使用的代码如下:Spead语法不能打字稿的类
interface ChildrenPropsType {
children: Array<TheElement<any>>
}
class TheElement<PropsType extends object> {
props: PropsType & ChildrenPropsType;
constructor(props: PropsType, children: ChildrenPropsType) {
this.props = {
children:children,
...props
}
}
}
Error: TS2698:Spread types may only be created from object types.
如何解决这个问题?
tsc --version
Version 2.5.2
传播目前不支持泛型。你可以通过'......道具任意'来解决这个问题。 [相关问题](https://github.com/Microsoft/TypeScript/issues/10727) –