File: extendArray.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (32 lines) | stat: -rw-r--r-- 944 bytes parent folder | download | duplicates (4)
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
tests/cases/compiler/extendArray.ts(7,19): error TS2304: Cannot find name '_element'.
tests/cases/compiler/extendArray.ts(7,32): error TS2304: Cannot find name '_element'.


==== tests/cases/compiler/extendArray.ts (2 errors) ====
    var a = [1,2];
    a.forEach(function (v,i,a) {});
    
    
    declare module _Core {
      interface Array {
        collect(fn:(e:_element) => _element[]) : any[];
                      ~~~~~~~~
!!! error TS2304: Cannot find name '_element'.
                                   ~~~~~~~~
!!! error TS2304: Cannot find name '_element'.
      }
    }
    
    
    var arr = (<any>Array).prototype;
    arr.collect = function (fn) {
        var res = [];
        for (var i = 0; i < this.length; ++i) {
            var tmp = fn(this[i]);
            for (var j = 0; j < tmp.length; ++j) {
                res.push(tmp[j]);
            }
        }
        return res;
    };