2014-09-12 22:35:07 +02:00
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(17,15): error TS1003: Identifier expected.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(4,9): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(5,15): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(10,9): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(11,15): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(23,9): error TS2304: Cannot find name 'x'.
2014-07-13 01:04:16 +02:00
==== 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
~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'x'.
2014-07-13 01:04:16 +02:00
b: typeof x; // error
~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'x'.
2014-07-13 01:04:16 +02:00
constructor(x) { }
}
class D {
a = x; // error
~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'x'.
2014-07-13 01:04:16 +02:00
b: typeof x; // error
~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'x'.
2014-07-13 01:04:16 +02:00
constructor(public x) { }
}
class E {
a = this.x; // ok
b: typeof this.x; // error
~~~~
2014-09-12 00:19:57 +02:00
!!! error TS1003: Identifier expected.
2014-07-13 01:04:16 +02:00
constructor(public x) { }
}
class F<T> {
a = this.x; // ok
b = x; // error
~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'x'.
2014-07-13 01:04:16 +02:00
constructor(public x: T) { }
}