mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
generics2.ts(17,14): error TS2741: Property 'b' is missing in type 'A' but required in type 'B'.
|
|
generics2.ts(20,9): error TS2314: Generic type 'G<T, U>' requires 2 type argument(s).
|
|
generics2.ts(21,9): error TS2314: Generic type 'G<T, U>' requires 2 type argument(s).
|
|
|
|
|
|
==== generics2.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: {
|
|
x: { a: string; }
|
|
y: { a: string; b: string; c: string };
|
|
}; // 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
|
|
~
|
|
!!! error TS2741: Property 'b' is missing in type 'A' but required in type 'B'.
|
|
!!! related TS2728 generics2.ts:2:25: 'b' is declared here.
|
|
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
|
|
~~~~~~
|
|
!!! error TS2314: Generic type 'G<T, U>' requires 2 type argument(s).
|
|
var v7: G; // Error, no type arguments
|
|
~
|
|
!!! error TS2314: Generic type 'G<T, U>' requires 2 type argument(s).
|
|
|