Propagation of props response in tsx in typescript 2.3.1

I have code that was used to compile in typescript 2.2, but does not work in 2.3.1:

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

Now I get:

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

I suspect that this has been fixed with PR (no writing moment), but so far there is a way around this problem?

+5
source share
1 answer

I get a similar error with typescript@2.3.2
Here's a quick workaround: <div { ...this.props as any }></div>

0
source

Source: https://habr.com/ru/post/1267237/


All Articles