File: generics2.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (37 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
tests/cases/compiler/generics2.ts(17,14): error TS2344: Type 'A' does not satisfy the constraint 'B'.
  Property 'b' is missing in type 'A' but required in type 'B'.
tests/cases/compiler/generics2.ts(20,9): error TS2314: Generic type 'G<T, U>' requires 2 type argument(s).
tests/cases/compiler/generics2.ts(21,9): error TS2314: Generic type 'G<T, U>' requires 2 type argument(s).


==== tests/cases/compiler/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 TS2344: Type 'A' does not satisfy the constraint 'B'.
!!! error TS2344:   Property 'b' is missing in type 'A' but required in type 'B'.
!!! related TS2728 tests/cases/compiler/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).