TypeScript/tests/baselines/reference/classExtendingClassLikeType.errors.txt
2015-06-15 16:14:28 -07:00

70 lines
2.2 KiB
Plaintext

tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2304: Cannot find name 'Base'.
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(45,18): error TS2508: No base constructor has the specified number of type arguments.
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(56,18): error TS2510: Base constructors must all have the same return type.
==== tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts (3 errors) ====
interface Base<T, U> {
x: T;
y: U;
}
// Error, no Base constructor function
class D0 extends Base<string, string> {
~~~~
!!! error TS2304: Cannot find name 'Base'.
}
interface BaseConstructor {
new (x: string, y: string): Base<string, string>;
new <T>(x: T): Base<T, T>;
new <T>(x: T, y: T): Base<T, T>;
new <T, U>(x: T, y: U): Base<T, U>;
}
declare function getBase(): BaseConstructor;
class D1 extends getBase() {
constructor() {
super("abc", "def");
this.x = "x";
this.y = "y";
}
}
class D2 extends getBase() <number> {
constructor() {
super(10);
super(10, 20);
this.x = 1;
this.y = 2;
}
}
class D3 extends getBase() <string, number> {
constructor() {
super("abc", 42);
this.x = "x";
this.y = 2;
}
}
// Error, no constructors with three type arguments
class D4 extends getBase() <string, string, string> {
~~~~~~~~~
!!! error TS2508: No base constructor has the specified number of type arguments.
}
interface BadBaseConstructor {
new (x: string): Base<string, string>;
new (x: number): Base<number, number>;
}
declare function getBadBase(): BadBaseConstructor;
// Error, constructor return types differ
class D5 extends getBadBase() {
~~~~~~~~~~~~
!!! error TS2510: Base constructors must all have the same return type.
}