2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts (7 errors) ====
|
|
|
|
class C<T extends number> {
|
|
|
|
x: T;
|
|
|
|
get X(): T { return null; }
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-07-13 01:04:16 +02:00
|
|
|
foo(): T {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class D extends C<number> {
|
|
|
|
x: any;
|
|
|
|
get X(): any {
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-07-13 01:04:16 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
foo(): any {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static y: any;
|
|
|
|
static get Y(): any {
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-07-13 01:04:16 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
static bar(): any {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if D is a valid class definition than E is now not safe tranisitively through C
|
|
|
|
class E<T extends string> extends D {
|
|
|
|
x: T;
|
|
|
|
get X(): T { return ''; } // error
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-07-13 01:04:16 +02:00
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'T'.
|
2014-07-13 01:04:16 +02:00
|
|
|
foo(): T {
|
|
|
|
return ''; // error
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'T'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var c: C<number>;
|
|
|
|
var d: D;
|
|
|
|
var e: E<string>;
|
|
|
|
|
|
|
|
c = d;
|
|
|
|
c = e;
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2322: Type 'E<string>' is not assignable to type 'C<number>':
|
|
|
|
!!! error TS2322: Types of property 'x' are incompatible:
|
|
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
2014-07-13 01:04:16 +02:00
|
|
|
var r = c.foo(); // e.foo would return string
|