PhpStorm 2021.2 Help

Code Inspection: Unsound type guard check

Reports a typeof or instanceof unsound type guard check. The typeof x type guard can be unsound in one of the following two cases:

  • typeof x never corresponds to the specified value (for example, typeof x === 'number' when x is of the type 'string | boolean')

  • typeof x always corresponds to the specified value (for example, typeof x === 'string' when x is of the type 'string')


The x instanceof A type guard can be unsound in one of the following two cases:
  • The type of x is not related to A

  • The type of x is A or a subtype of A

Suppress an inspection in the editor

  1. Position the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 16 July 2021