34 lines
No EOL
1.4 KiB
Text
34 lines
No EOL
1.4 KiB
Text
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(7,7): error TS2421: Class 'D' incorrectly implements interface 'C<number>':
|
|
Types of property 'bar' are incompatible:
|
|
Type '() => string' is not assignable to type '() => number':
|
|
Type 'string' is not assignable to type 'number'.
|
|
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(12,5): error TS2323: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(16,5): error TS2323: Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
==== tests/cases/compiler/extendAndImplementTheSameBaseType2.ts (3 errors) ====
|
|
class C<T> {
|
|
foo: number
|
|
bar(): T {
|
|
return null;
|
|
}
|
|
}
|
|
class D extends C<string> implements C<number> {
|
|
~
|
|
!!! error TS2421: Class 'D' incorrectly implements interface 'C<number>':
|
|
!!! error TS2421: Types of property 'bar' are incompatible:
|
|
!!! error TS2421: Type '() => string' is not assignable to type '() => number':
|
|
!!! error TS2421: Type 'string' is not assignable to type 'number'.
|
|
baz() { }
|
|
}
|
|
|
|
var d: D = new D();
|
|
var r: string = d.foo;
|
|
~
|
|
!!! error TS2323: Type 'number' is not assignable to type 'string'.
|
|
var r2: number = d.foo;
|
|
|
|
var r3: string = d.bar();
|
|
var r4: number = d.bar();
|
|
~~
|
|
!!! error TS2323: Type 'string' is not assignable to type 'number'. |