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'
whenx
is of the type 'string | boolean')typeof x
always corresponds to the specified value (for example,typeof x === 'string'
whenx
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 toA
The type of
x
isA
or a subtype ofA
Suppress an inspection in the editor
Place the caret at the highlighted line and press Alt+Enter or click .
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.
Last modified: 11 February 2024