31 lines
No EOL
929 B
Text
31 lines
No EOL
929 B
Text
==== tests/cases/compiler/getAndSetNotIdenticalType3.ts (5 errors) ====
|
|
class A<T> { foo: T; }
|
|
|
|
class C<T> {
|
|
data: A<number>;
|
|
get x(): A<number> {
|
|
~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
return this.data;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
}
|
|
~~~~~
|
|
!!! 'get' and 'set' accessor must have the same type.
|
|
set x(v: A<string>) {
|
|
~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
this.data = v;
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
~~~~~~~~~
|
|
!!! Type 'A<string>' is not assignable to type 'A<number>':
|
|
!!! Type 'string' is not assignable to type 'number'.
|
|
}
|
|
~~~~~
|
|
!!! 'get' and 'set' accessor must have the same type.
|
|
}
|
|
|
|
var x = new C();
|
|
var r = x.x;
|
|
x.x = r; |