gpt4 book ai didi

typescript - Angular 2 beta.17 : Property 'map' does not exist on type 'Observable'

转载 作者:太空狗 更新时间:2023-10-29 16:44:15 25 4
gpt4 key购买 nike

我刚刚从 Angular 2 beta16 升级到 beta17,这又需要 rxjs 5.0.0-beta.6。 (这里的变更日志:https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta17-2016-04-28)在 beta16 中,所有关于 Observable/map 功能的工作都很好。我升级后出现以下错误,并在 typescript 尝试转译时发生:

  1. Property 'map' does not exist on type 'Observable' (anywhere where I've used map with an observable)
  2. c:/path/node_modules/rxjs/add/operator/map.d.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
  3. c:/path/node_modules/rxjs/add/operator/map.d.ts(2,16): error TS2436: Ambient module declaration cannot specify a relative module name.

我看过这个问题/答案,但它没有解决问题:Observable errors with Angular2 beta.12 and RxJs 5 beta.3

我的 appBoot.ts 看起来像这样(我已经在引用 rxjs/map):

///<reference path="./../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from "angular2/platform/browser";
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
[stuff]
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import {enableProdMode} from 'angular2/core';
import { Title } from 'angular2/platform/browser';


//enableProdMode();
bootstrap(AppDesktopComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
Title
]);

有人知道发生了什么事吗?

最佳答案

你需要导入map操作符:

import 'rxjs/add/operator/map'

关于typescript - Angular 2 beta.17 : Property 'map' does not exist on type 'Observable<Response>' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36947748/

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