Inspectopedia Help

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

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

SuspiciousTypeOfGuard
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | JavaScript and TypeScript | Control flow issues

Last modified: 11 September 2024