File: typeArgInference2.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
tests/cases/compiler/typeArgInference2.ts(12,52): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
  Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'.
    Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'.


==== tests/cases/compiler/typeArgInference2.ts (1 errors) ====
    interface Item {
        name: string;
    }
    
    declare function foo<T extends Item>(x?: T, y?: T): T;
    
    var z1 = foo(null);                   // any
    var z2 = foo();                       // Item
    var z3 = foo({ name: null });         // { name: any }
    var z4 = foo({ name: "abc" });        // { name: string }
    var z5 = foo({ name: "abc", a: 5 });  // { name: string; a: number }
    var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 });  // error
                                                       ~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453:   Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'.
!!! error TS2453:     Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'.