加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

typescript – Angular 2 beta.17:属性’map’不存在类型’Obse

发布时间:2020-12-17 08:50:06 所属栏目:安全 来源:网络整理
导读:我刚刚从Angular2 beta16升级到beta17,这反过来又需要rxjs 5.0.0-beta.6。 (更改日志在这里: https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta17-2016-04-28)在beta16所有工作良好关于Observable /地图功能。以下错误出现在我升级后
我刚刚从Angular2 beta16升级到beta17,这反过来又需要rxjs 5.0.0-beta.6。 (更改日志在这里: https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta17-2016-04-28)在beta16所有工作良好关于Observable /地图功能。以下错误出现在我升级后,发生时打字稿尝试transpile:
  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 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
]);

任何人都有任何想法是什么正在haywire?

我将我的gulp-typescript插件升级到最新版本(2.13.0),现在它编译毫无困难。

更新1:我以前使用gulp-typescript版本2.12.0

更新2:如果您升级到Angular 2.0.0-rc.1,您需要在您的appBoot.ts文件中执行以下操作:

///<reference path="./../typings/browser/ambient/es6-shim/index.d.ts"/>
import { bootstrap } from "@angular/platform-browser-dynamic";
import { ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { HTTP_PROVIDERS } from '@angular/http';
import { AppComponent } from "./path/AppComponent";
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
// import 'rxjs/Rx'; this will load all features
import { enableProdMode } from '@angular/core';
import { Title } from '@angular/platform-browser';



//enableProdMode();
bootstrap(AppComponent,Title
]);

重要的是引用es6-shim / index.d.ts

这假设您已经安装了es6-shim类型,如下所示:

更多关于从Angular这里安装的打字:https://angular.io/docs/ts/latest/guide/typescript-configuration.html#!#typings

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读