TypeScript Language Specification v1.5
TypeScript Language Specification v1.5
TypeScript Language Specification v1.5
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Initializer expressions for instance member variables are evaluated in the scope of the class constructor<br />
body but are not permitted to reference parameters or local variables of the constructor. This effectively<br />
means that entities from outer scopes by the same name as a constructor parameter or local variable are<br />
inaccessible in initializer expressions for instance member variables.<br />
Since instance member variable initializers are equivalent to assignments to properties of this in the<br />
constructor, the example<br />
class Employee {<br />
public name: string;<br />
public address: string;<br />
public retired = false;<br />
public manager: Employee = null;<br />
public reports: Employee[] = [];<br />
}<br />
is equivalent to<br />
class Employee {<br />
public name: string;<br />
public address: string;<br />
public retired: boolean;<br />
public manager: Employee;<br />
public reports: Employee[];<br />
constructor() {<br />
this.retired = false;<br />
this.manager = null;<br />
this.reports = [];<br />
}<br />
}<br />
8.4.2 Member Function Declarations<br />
A member function declaration declares an instance member function or a static member function.<br />
MemberFunctionDeclaration:<br />
MemberFunctionOverloads opt MemberFunctionImplementation<br />
MemberFunctionOverloads:<br />
MemberFunctionOverload<br />
MemberFunctionOverloads MemberFunctionOverload<br />
MemberFunctionOverload:<br />
AccessibilityModifier opt static opt PropertyName CallSignature ;<br />
MemberFunctionImplementation:<br />
AccessibilityModifier opt static opt PropertyName CallSignature { FunctionBody }<br />
121