打字稿:如何解决'rxjs / Rx没有导出成员'SubscriptionLike' [英] Typescript : How to resolve 'rxjs/Rx has no exported member 'SubscriptionLike'

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

问题描述

我正在尝试按照此示例 https://www.youtube.com/watch ?v = gxCu5TEmxXE ,但在执行 tsc -p 时,出现错误。我需要导入一些东西吗?

I'm trying to follow this example here https://www.youtube.com/watch?v=gxCu5TEmxXE, but when doing tsc -p, I get an error. Is there something I need to import?

错误:

node_modules/@angular/common/src/location/location.d.ts(1,10):错误TS2305:模块'... functions / node_modules / rxjs / Rx'没有导出成员'SubscriptionLike' 。

TS FILE

import "zone.js/dist/zone-node";
import * as functions from "firebase-functions";
import * as express from "express"
import { renderModuleFactory } from "@angular/platform-server"
import * as fs from "fs"

const document = fs.readFileSync(__dirname + "/dist-server/index.html", "utf8");
const AppServerModuleNgFactory = require(__dirname + "/dist-server/main.bundle");

const app = express();
app.get("**", (req, res) => {
    const url = req.path;
    renderModuleFactory(AppServerModuleNgFactory, { document, url }).then(html => {
        res.send(html);
    });
});
exports.post = functions.https.onRequest(app);

CONFIG

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "rootDir": ".",
    "outDir": "../functions"
  },
  "files": [
    "index.ts"
  ]
}


推荐答案

我在遇到同样的问题之后关注

I faced the same issue after following

从djamware学习本教程

经过大量搜索,我发现通过安装的Rxjs软件包Angular 6不支持本教程中的说明。

After searching a lot, I have found that Rxjs package that is installed through instructions in this tutorial is not supported with Angular 6.

Angular 6不适用于RxJS 5.5,但使用RxJS 6.

Angular 6 does not work with RxJS 5.5 but with RxJS 6.

npm i rxjs@6

运行以上在cli中的命令,这应该可以解决您的问题。它确实在我的情况下。

Run the above command in cli and that should fix your problem. It did in my case.

这篇关于打字稿:如何解决'rxjs / Rx没有导出成员'SubscriptionLike'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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