== Why is this an issue?

Parameter properties let you both create and initialize a member in one place, and omit an explicit member declaration and the assignment of the constructor parameter to the member. To use a parameter property, add an accessibility modifier or ``++readonly++``, or both in front of the constructor parameter.

----
constructor(readonly name: string, private age: number) { // creates 2 initialized members "name" and "age"
}
----
While this syntax is very concise it might be confusing for developers who are new to TypeScript. 

Shared conventions allow teams to collaborate efficiently. This rule checks that either parameter properties are used everywhere or not at all.


=== Noncompliant code example

Using the default parameter ``++forceParameterProperties++`` value ``++true++``:

[source,javascript]
----
class Person {
  name: number;
  constructor(name: string) {
    this.name = name; // Noncompliant, parameter property can be used
  }
}
----


=== Compliant solution

[source,javascript]
----
class Person {
  constructor(public name: string) {
  }
}
----



ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

* Usage of parameter properties has been disallowed.
or

* Use parameter properties instead of assigning to members in the constructor body.


=== Parameters

.forceParameterProperties
****

----
true
----

Forces to use parameter properties when true, forbids their use when false
****


=== Highlighting

* parameter property declaration
or

* assignment statement


'''
== Comments And Links
(visible only on this page)

=== on 16 Feb 2018, 14:29:06 Ann Campbell wrote:
\[~elena.vilchik] message and highlighting are both needed. Since you're (currently) the likely implementer, this may seem redundant but it's good to have a record. And you might not end up as the implementer after all. :-)


Otherwise, nicely done!

endif::env-github,rspecator-view[]
