51 lines
1.5 KiB
Text
51 lines
1.5 KiB
Text
|
==== tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts (6 errors) ====
|
||
|
module NonGeneric {
|
||
|
class C {
|
||
|
x: string;
|
||
|
get y() {
|
||
|
~
|
||
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||
|
return 1;
|
||
|
}
|
||
|
set y(v) { }
|
||
|
~
|
||
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||
|
fn() { return this; }
|
||
|
constructor(public a: number, private b: number) { }
|
||
|
}
|
||
|
|
||
|
var c = new C(1, 2);
|
||
|
var r = c.fn();
|
||
|
var r2 = r.x;
|
||
|
var r3 = r.y;
|
||
|
r.y = 4;
|
||
|
var r6 = c.y(); // error
|
||
|
~~~~~
|
||
|
!!! Cannot invoke an expression whose type lacks a call signature.
|
||
|
|
||
|
}
|
||
|
|
||
|
module Generic {
|
||
|
class C<T,U> {
|
||
|
x: T;
|
||
|
get y() {
|
||
|
~
|
||
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||
|
return null;
|
||
|
}
|
||
|
set y(v: U) { }
|
||
|
~
|
||
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||
|
fn() { return this; }
|
||
|
constructor(public a: T, private b: U) { }
|
||
|
}
|
||
|
|
||
|
var c = new C(1, '');
|
||
|
var r = c.fn();
|
||
|
var r2 = r.x;
|
||
|
var r3 = r.y;
|
||
|
r.y = '';
|
||
|
var r6 = c.y(); // error
|
||
|
~~~~~
|
||
|
!!! Cannot invoke an expression whose type lacks a call signature.
|
||
|
}
|