Property 'shouldComponentUpdate' is not assignable to the same property

There is a little bit annoying to use React with TypeScript, because the last one today is does not contains all required error describing tips. So, probably an error in your case is binded with non-finished return call from shouldComponentUpdate method.

Try next and see what will happen:

  shouldComponentUpdate(nextProps: IProps) { // error here
    console.log(nextProps, 'nextProps')
    return true
  }

I believe this is due to the fact that shouldComponentUpdate is expected to return a boolean. You are returning void because you are not explicitly returning anything. The default is to return true, so merely adding that as your final statement in the function fixes the issue.

For more information, see for example the react documentation: https://reactjs.org/docs/react-component.html#shouldcomponentupdate.


Typescript expects you to define the type each of the passed parameters and the type of the returned value. If your function does not have a return statement then you can use : void.

  shouldComponentUpdate(nextProps: IProps): void {
    console.log(nextProps, 'nextProps')
  }