我刚刚从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:
- Property ‘map’ does not exist on type ‘Observable’ (anywhere where i’ve used map with an observable)
- c:/path/node_modules/rxjs/add/operator/map.d.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
- 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
更多关于从Angular这里安装的打字:https://angular.io/docs/ts/latest/guide/typescript-configuration.html#!#typings