23 lines
951 B
Text
23 lines
951 B
Text
|
==== tests/cases/compiler/generics1.ts (3 errors) ====
|
||
|
interface A { a: string; }
|
||
|
interface B extends A { b: string; }
|
||
|
interface C extends B { c: string; }
|
||
|
interface G<T, U extends B> {
|
||
|
x: T;
|
||
|
y: U;
|
||
|
}
|
||
|
var v1: G<A, C>; // Ok
|
||
|
var v2: G<{ a: string }, C>; // Ok, equivalent to G<A, C>
|
||
|
var v3: G<A, A>; // Error, A not valid argument for U
|
||
|
~~~~~~~
|
||
|
!!! Type 'A' does not satisfy the constraint 'B':
|
||
|
!!! Property 'b' is missing in type 'A'.
|
||
|
var v4: G<G<A, B>, C>; // Ok
|
||
|
var v5: G<any, any>; // Error, any does not satisfy constraint B
|
||
|
var v6: G<any>; // Error, wrong number of arguments
|
||
|
~~~~~~
|
||
|
!!! Generic type 'G<T, U>' requires 2 type argument(s).
|
||
|
var v7: G; // Error, no type arguments
|
||
|
~
|
||
|
!!! Generic type 'G<T, U>' requires 2 type argument(s).
|
||
|
|