PhpStorm 2021.2 Help

Code Inspection: Assigned constructor field parameter

Reports 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.

class Foo { constructor(private p: number) { p = 1; //must be this.p = 1; } }

Suppress an inspection in the editor



Last modified: 15 September 2021