gpt4 book ai didi

typescript - 类型 'Observable<{}>' 不可分配给类型 'Observable | boolean '

转载 作者:太空狗 更新时间:2023-10-29 17:33:14 26 4
gpt4 key购买 nike

我正在努力关注 this tutorial ,但我收到错误。

  1. 路径匹配:“完整”。我尝试将“@angular/router”更改为“3.0.0-beta.2”,仍然是同样的问题。

我的依赖项:

"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/platform-server": "2.0.0-rc.3",
"@angular/router": "3.0.0-beta.2",
"@angular/router-deprecated": "2.0.0-rc.2",
"nativescript-angular": "0.2.0",
"tns-core-modules": "^2.1.0"
},
  1. 类型“Observable<{}>”不可分配给类型“Observable”,它指向行'return o'

    canDeactivate(): Observable<boolean> | boolean {

    if (!this.crisis || this.crisis.name === this.editName) {

    return true;
    }
    let p = this.dialogService.confirm('Discard changes?');
    let o = Observable.fromPromise(p);
    return o;
    }

谁能指导我修复这些错误?谢谢。

最佳答案

您可以尝试转换:

canDeactivate(): Observable<boolean> | boolean {

if (!this.crisis || this.crisis.name === this.editName) {

return true;
}
let p = this.dialogService.confirm('Discard changes?');
let o = <Observable<boolean>>Observable.fromPromise(p);
return o;
}

关于typescript - 类型 'Observable<{}>' 不可分配给类型 'Observable<boolean> | boolean ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38299484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com