Angular 2:Array.find不是函数

时间:2016-12-29 08:28:08

标签: arrays angular typescript

selected: Array<{ object: Mill | Paver | Vehicle, marker: L.Marker }> = [];

这是我想要查找的数组。

select(object: Mill | Paver | Vehicle) {
    if (!this.selected.find(o => o.object === object)) {
        if (object instanceof Paver || object instanceof Vehicle) {
            this.selected.push(this.getTripsFromPlanning(object));
        } else {
            this.selected.push({
                object: object,
                marker: this.mapService.addMarker(object.location, object.name, false, 0)
            });
        };
    }
}

当我调用此函数时,它返回此错误:this.selected.find不是函数。

我该如何解决这个问题?

编辑:

打字稿版本是2.0.10

tsconfig文件:

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "suppressImplicitAnyIndexErrors": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es6",
    "typeRoots": [
      "../node_modules/@types"
    ]
  }
}

0 个答案:

没有答案