File: destructuringParameterDeclaration5.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (81 lines) | stat: -rw-r--r-- 3,355 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,4): error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'.
  Types of property 'y' are incompatible.
    Type 'Class' is not assignable to type 'D'.
      Property 'foo' is missing in type 'Class'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(48,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'.
  Property 'y' is missing in type '{}'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,4): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'.
  Types of property 'y' are incompatible.
    Type 'number' is not assignable to type 'D'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,4): error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'.
  Types of property 'y' are incompatible.
    Type 'string' is not assignable to type 'D'.


==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts (4 errors) ====
    // Parameter Declaration with generic
    
    interface F { }
    class Class implements F {
        constructor() { }
    }
    
    class SubClass extends Class {
        foo: boolean;
        constructor() { super(); }
    }
    
    class D implements F {
        foo: boolean
        constructor() { }
    }
    
    class SubD extends D {
        bar: number
        constructor() {
            super();
        }
    }
    
    
    function d0<T extends Class>({x} = { x: new Class() }) { }
    function d1<T extends F>({x}: { x: F }) { }
    function d2<T extends Class>({x}: { x: Class }) { }
    function d3<T extends D>({y}: { y: D }) { }
    function d4<T extends D>({y} = { y: new D() }) { }
    
    var obj = new Class();
    d0({ x: 1 });
    d0({ x: {} });
    d0({ x: "string" });
    
    d1({ x: new Class() });
    d1({ x: {} });
    d1({ x: "string" });
    
    d2({ x: new SubClass() });
    d2({ x: {} });
    
    d3({ y: new SubD() });
    d3({ y: new SubClass() });
    // Error
    d3({ y: new Class() });
       ~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'.
!!! error TS2345:   Types of property 'y' are incompatible.
!!! error TS2345:     Type 'Class' is not assignable to type 'D'.
!!! error TS2345:       Property 'foo' is missing in type 'Class'.
    d3({});
       ~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'.
!!! error TS2345:   Property 'y' is missing in type '{}'.
    d3({ y: 1 });
       ~~~~~~~~
!!! error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'.
!!! error TS2345:   Types of property 'y' are incompatible.
!!! error TS2345:     Type 'number' is not assignable to type 'D'.
    d3({ y: "world" });
       ~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'.
!!! error TS2345:   Types of property 'y' are incompatible.
!!! error TS2345:     Type 'string' is not assignable to type 'D'.