我最近更新了我的离子3项目中的很多npm包。我收到与传递给watchPosition()的参数类型相关的错误。在更新软件包之前,我没有收到此错误。我查看了文档,看来这些参数没有改变。我继续尝试在选项中注释掉不同的行,以排除它不能采取的选项。请让我知道如何解决这个问题。
以下是运行ionic cordova build ios时收到的错误
Argument of type '{ maximumAge: number; timeout: number; enableHighAccuracy: boolean; }' is not assignable
to parameter of type 'PositionCallback'. Type '{ maximumAge: number; timeout: number; enableHighAccuracy:
boolean; }' provides no match for the signature '(position: Position): void'.
以下是我的代码。
startTracking(position) {
let options = {
maximumAge: 3000,
timeout: 5000,
enableHighAccuracy: true
};
return Observable.create(observer => {
this.watch = this.geolocation.watchPosition(options)
.filter((p: any) => p.code === undefined)
.subscribe(pos => {
this.zone.run(() => {
this.lat = pos.coords.latitude;
this.lng = pos.coords.longitude;
this.time = pos.coords.timestamp;
this.getZip()
.subscribe(data => {
observer.next(JSON.parse(data));
});
})
})
});
}