TypeScript/tests/baselines/reference/initializerReferencingConstructorParameters.errors.txt
2014-07-12 17:30:19 -07:00

38 lines
1.1 KiB
Plaintext

==== tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts (6 errors) ====
// Initializer expressions for instance member variables are evaluated in the scope of the class constructor body but are not permitted to reference parameters or local variables of the constructor.
class C {
a = x; // error
~
!!! Cannot find name 'x'.
b: typeof x; // error
~
!!! Cannot find name 'x'.
constructor(x) { }
}
class D {
a = x; // error
~
!!! Cannot find name 'x'.
b: typeof x; // error
~
!!! Cannot find name 'x'.
constructor(public x) { }
}
class E {
a = this.x; // ok
b: typeof this.x; // error
~~~~
!!! Identifier expected.
constructor(public x) { }
}
class F<T> {
a = this.x; // ok
b = x; // error
~
!!! Cannot find name 'x'.
constructor(public x: T) { }
}