1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A<string>' is not assignable to type 'A<T>'.
Type 'string' is not assignable to type 'T'.
==== tests/cases/compiler/getAndSetNotIdenticalType2.ts (5 errors) ====
class A<T> { foo: T; }
class C<T> {
data: A<T>;
get x(): A<T> {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
return this.data;
}
set x(v: A<string>) {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
this.data = v;
~~~~~~~~~
!!! error TS2322: Type 'A<string>' is not assignable to type 'A<T>'.
!!! error TS2322: Type 'string' is not assignable to type 'T'.
}
}
var x = new C();
var r = x.x;
x.x = r;
|