File: arrowFunctionContexts.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 (129 lines) | stat: -rw-r--r-- 5,148 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(3,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(3,7): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(19,1): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(31,9): error TS2322: Type '() => number' is not assignable to type 'E'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(32,16): error TS2332: 'this' cannot be referenced in current location.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(44,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(44,11): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(60,5): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,13): error TS2322: Type '() => number' is not assignable to type 'E'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(73,20): error TS2332: 'this' cannot be referenced in current location.


==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (10 errors) ====
    
    // Arrow function used in with statement
    with (window) {
    ~~~~~~~~~~~~~
!!! error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
          ~~~~~~
!!! error TS2304: Cannot find name 'window'.
        var p = () => this;
    }
    
    // Arrow function as argument to super call
    class Base {
        constructor(n: any) { }
    }
    
    class Derived extends Base {
        constructor() {
            super(() => this);
        }
    }
    
    // Arrow function as function argument
    window.setTimeout(() => null, 100);
    ~~~~~~
!!! error TS2304: Cannot find name 'window'.
    
    // Arrow function as value in array literal
    
    var obj = (n: number) => '';
    var obj: { (n: number): string; }; // OK
    
    var arr = [(n: number) => ''];
    var arr: { (n: number): string; }[]; // Incorrect error here (bug 829597)
    
    // Arrow function as enum value
    enum E {
        x = () => 4, // Error expected
            ~~~~~~~
!!! error TS2322: Type '() => number' is not assignable to type 'E'.
        y = (() => this).length // error, can't use this in enum
                   ~~~~
!!! error TS2332: 'this' cannot be referenced in current location.
    }
    
    // Arrow function as module variable initializer
    module M {
        export var a = (s) => '';
        var b = (s) => s;
    }
    
    // Repeat above for module members that are functions? (necessary to redo all of them?)
    module M2 {
        // Arrow function used in with statement
        with (window) {
        ~~~~~~~~~~~~~
!!! error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
              ~~~~~~
!!! error TS2304: Cannot find name 'window'.
            var p = () => this;
        }
    
        // Arrow function as argument to super call
        class Base {
            constructor(n: any) { }
        }
    
        class Derived extends Base {
            constructor() {
                super(() => this);
            }
        }
    
        // Arrow function as function argument
        window.setTimeout(() => null, 100);
        ~~~~~~
!!! error TS2304: Cannot find name 'window'.
    
        // Arrow function as value in array literal
    
        var obj = (n: number) => '';
        var obj: { (n: number): string; }; // OK
    
        var arr = [(n: number) => ''];
        var arr: { (n: number): string; }[]; // Incorrect error here (bug 829597)
    
        // Arrow function as enum value
        enum E {
            x = () => 4, // Error expected
                ~~~~~~~
!!! error TS2322: Type '() => number' is not assignable to type 'E'.
            y = (() => this).length
                       ~~~~
!!! error TS2332: 'this' cannot be referenced in current location.
        }
    
        // Arrow function as module variable initializer
        module M {
            export var a = (s) => '';
            var b = (s) => s;
        }
    
    }
    
    // <Identifier>(ParamList) => { ... } is a generic arrow function
    var generic1 = <T>(n: T) => [n];
    var generic1: { <T>(n: T): T[] }; // Incorrect error, Bug 829597
    var generic2 = <T>(n: T) => { return [n]; };
    var generic2: { <T>(n: T): T[] };
    
    // <Identifier> ((ParamList) => { ... } ) is a type assertion to an arrow function
    var asserted1 = <any>((n) => [n]);
    var asserted1: any;
    var asserted2 = <any>((n) => { return n; });
    var asserted2: any;