TypeScript/tests/baselines/reference/genericTypeAssertions2.errors.txt
2014-09-05 17:09:00 -07:00

26 lines
No EOL
1.1 KiB
Text

==== tests/cases/compiler/genericTypeAssertions2.ts (3 errors) ====
class A<T> { foo(x: T) { } }
class B<T> extends A<T> {
bar(): T {
return null;
}
}
var foo = new A<number>();
var r: A<string> = <B<string>>new B();
var r2: A<number> = <B<string>>new B(); // error
~~
!!! Type 'B<string>' is not assignable to type 'A<number>':
!!! Types of property 'foo' are incompatible:
!!! Type '(x: string) => void' is not assignable to type '(x: number) => void':
!!! Types of parameters 'x' and 'x' are incompatible:
!!! Type 'string' is not assignable to type 'number'.
var r3: B<number> = <A<number>>new B(); // error
~~
!!! Type 'A<number>' is not assignable to type 'B<number>':
!!! Property 'bar' is missing in type 'A<number>'.
var r4: A<number> = <A<number>>new A();
var r5: A<number> = <A<number>>[]; // error
~~~~~~~~~~~~~
!!! Neither type 'undefined[]' nor type 'A<number>' is assignable to the other:
!!! Property 'foo' is missing in type 'undefined[]'.