6

I have some code that used to compiles fine in typescript 2.2, but fails in 2.3.1:

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

I now get:

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

I suspect that this is fixed by this PR (unmerged at time of writing), but in the meantime, is there a way to workaround around this issue?

Stephen Wan
  • 980
  • 7
  • 11

1 Answers1

0

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

Tom Esterez
  • 21,567
  • 8
  • 39
  • 44