PhpStorm 2019.3 Help

Code Inspections in TypeScript

This topic lists all PhpStorm code inspections available in TypeScript.

You can toggle specific inspections or change their severity level on the Editor | Inspections page of PhpStorm settings Ctrl+Alt+S.



Default Severity

Redundant type

Checks type arguments for redundancy when a reference provides the type with default values

Weak Warning Weak warning
Equality operator may cause type coercion

Reports usages of equality operators which may cause unexpected type coercions.It is considered a good practice to use the type-safe equality operators === and !==instead of their regular counterparts == and !=.

Depending on the option selected, this will either highlight:

  • All usages of == and != operators.

  • All usages except comparison with null. Some code styles allow using x == null as a replacement for x === null || x === undefined.

  • Only suspicious expressions, such as: == or != comparisons to 0, '', null, true, false, or undefined.

Reference to a UMD global

Report the use of references to a UMD global if the current file is a module.

Weak Warning Weak warning
Import can be shortened

Reports ES6 imports whose from part can be shortened by importing the parent directory.

Warning Warning
Unresolved JavaScript function

Checks that TypeScript called functions are valid.

Weak Warning Weak warning
Duplicated type

Checks union and intersection types for duplicates

Warning Warning
Abstract class constructor can be made protected

Suggests to make the constructor of an abstract class protected (because it is useless to have it public).

Weak Warning Weak warning
Required TypeScript library is not included in tsconfig.json

Checks that the TypeScript library files required for the symbol are listed under the 'lib' compiler option in tsconfig.json.

Error Error
Variable type is narrowed by a type guard

Highlights variable usages where variable type is narrowed by a type guard.Note that severity level doesn't affect this inspection.

Warning Warning
Type mismatch in 'any' type context

Checks TypeScript called function parameters, return values, assigned expressions to be of correct type in any type context.

Weak Warning Weak warning
Type mismatch

Checks that TypeScript called function parameters, return values, assigned expressions are of the correct type.

Error Error
Suspicious parameter assignment in constructor

Warns against a common mistake in TypeScript code, when a class field is declared as a constructor parameter, and then this parameter is assigned.
In this case, the corresponding field won't be assigned, only the local parameter value is modified.

Warning Warning

Runs TSLint - a linter for TypeScript.

The highlighting is based on the rule severity specified in the TSLint configuration file.Uncheck "Use rule severity from the configuration file" to use the same severity configured in this inspection for all TSLint rules.

Missing augmentation import

Checks that current file imports the augmentation module.

Info No highlighting, only fix

Generic type mismatch

Checks that a corresponding type argument is passed when a generic type is used in a function, interface or class declaration

Error Error
Missing option in tsconfig.json

Checks that required options are enabled in tsconfig.json, e.g. when using React JSX in .tsx files, the TypeScript configuration file contains 'jsx: "react"'.

Warning Warning
@private and @protected members accessibility

Checks that TypeScript private and protected members are visible in current context.

Weak Warning Weak warning
Field is assigned only in the constructor and can be made readonly

If a private field is assigned only in the constructor, it can be made readonly.

Weak Warning Weak warning
Unresolved JavaScript variable

Checks that TypeScript referenced variables and fields are valid.

Weak Warning Weak warning
Validate tsconfig.json

Validate usages of tsconfig.json properties.

Warning Warning
Explicit member types

Highlights type declarations that do not match the current code style.

By default, type declarations are highlighted as redundant when the type can be inferred from context, for example:

Highlights type declarations that do not match the current code style.

var pi: number = 3.14

Highlights type declarations that do not match the current code style.

Enabling any of the options below inverts this and suggests inserting an explicit type declaration even where the type can be inferred.

Info No highlighting, only fix

Validate imports

Validate TypeScript imports.

Error Error
Last modified: 27 March 2020