【问题标题】:Facing a strange issue with angular 5 development vs production codeAngular 5开发与生产代码面临一个奇怪的问题
【发布时间】:2018-07-17 14:11:39
【问题描述】:

以下代码在开发模式下运行良好: ng 服务 --open

addDriver(driver: any) {
   return fromPromise(this.db.insert('driver', driver));
}

但在部署到生产环境时失败并出现以下错误:ng build --prod

ERROR TypeError: Object(...) is not a function

this.db.insert 上收到此错误

我猜它与 ASI(自动分号插入)有关

非常感谢任何帮助。

提前致谢。

【问题讨论】:

    标签: javascript typescript rxjs angular5


    【解决方案1】:

    正如您猜对的那样,ASI 规则仅适用于特定语句,如 ECMAScript® 2016 Language Specification 所述

    包括以下情况——

    • 空语句
    • var声明
    • 表达式语句
    • do-while声明
    • continue声明
    • break声明
    • return声明
    • throw声明

    最好的解决方案是避免依赖ASI,因为它可能无法在所有情况下工作。

    参考资料 -

    SO Question 1

    SO Question 2

    【讨论】:

    • 感谢您的回答,但这与 rxjs 有关。显然 fromPromise 在 rxjs6 中无法正常工作。我将 fromPromise 更改为 'from' 并且成功了。
    猜你喜欢
    • 1970-01-01
    • 2018-06-10
    • 2014-05-18
    • 2019-04-25
    • 2012-05-01
    • 2017-02-07
    • 1970-01-01
    • 2019-04-12
    • 2010-11-27
    相关资源
    最近更新 更多