rxjs/Subscription没有导出的成员"Subscription" [英] rxjs/Subscription has no exported member 'Subscription'

查看:365
本文介绍了rxjs/Subscription没有导出的成员"Subscription"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的角度项目和所有依赖项更新到最新版本.没有太多麻烦,我解决了大多数依赖项问题,但是我仍然停留在RxJS上.这是我的package.json:

I updated my angular project and all my dependencies to latest version. Without to much trouble I solved most of the dependency issues, but I'm still stuck on RxJS. Here is my package.json:

  "dependencies": {
    "@angular-devkit/build-angular": "^0.6.0",
    "@angular/animations": "^6.0.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "angular-bootstrap-md": "^6.0.1",
    "core-js": "^2.5.5",
    "font-awesome": "^4.7.0",
    "rxjs": "^6.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "~6.0.0",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "6.0.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "electron": "^1.8.3",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.2",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.2",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^1.0.0",
    "protractor": "~5.3.1",
    "ts-node": "~6.0.2",
    "tslint": "~5.10.0",
    "typescript": "~2.7.2"

我只从RxJS导入两个模块:

I'm only importing two modules from RxJS:

import { fromPromise } from 'rxjs/observable/fromPromise';
import { Subscription } from 'rxjs/Subscription';

它们都给出相同的错误:

They are both giving the same error:

    [ts] Module '"***/node_modules/rxjs/Subscription"' has no exported
 member 'Subscription'.

fromPromise完全相同.这是我从Subscribtion.d.ts得到的错误消息(我没有以任何方式修改代码)

It's exactly the same for fromPromise. Here is the error message I'm getting from Subscribtion.d.ts (I have not modified the code in any way)

更新:

下面的答案通过Subscription解决了该问题,但是fromPromise仍然给出了相同的问题,即使它已正确导出:

The answers bellow solved the issue with Subscription but fromPromise still gives the same issue even though it's exported correctly:

export * from 'rxjs-compat/observable/fromPromise';

推荐答案

RxJS 6有很多重大更改.例如,原型方法为

There is a lot of breaking changes with RxJS 6. For example, prototype methods as

myObservable.map(data => data * 2)

将不再起作用,必须替换为

won't work anymore and must be replaced by

myObservable.pipe(map(data => data * 2))

所有详细信息都可以在这里找到: https ://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md

All details can be found here: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md

在您修复所有重大更改之前,您可以使用rxjs-compat(

Until you have fixed all breaking changes, you can make your old code work again with rxjs-compat (https://github.com/ReactiveX/rxjs/tree/master/compat).

需要此软件包才能与RxJS向后兼容 版本6之前的版本.它包含将运算符添加到的导入. Observable.prototypeObservable的创建方法.

This package is required to get backwards compatibility with RxJS previous to version 6. It contains the imports to add operators to Observable.prototype and creation methods to Observable.

键入以下内容进行安装:

Type this to install it:

npm install -s rxjs-compat

这篇关于rxjs/Subscription没有导出的成员"Subscription"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆