angular - ReferenceError: 在使用 |this| 之前必须调用超级构造函数 在 Ti 类构造函数中
问题描述
我正在开发一个 Angular 项目,最近从 Angular 5.2.10 更新到 Angular 6。在升级之前一切正常。
现在,每次我为生产编译我的代码时,虽然在编译期间没有任何错误,但我在运行时收到此错误:
ReferenceError: must call super constructor before using |this| in Ti class constructor
唯一使用 super 的打字稿类是
export class Exception extends Error {
private _statusCode: number;
constructor(statusCode: number, type: ExceptionType) {
super(ExceptionType[type]);
this._statusCode = statusCode;
}
get statusCode(): number {
return this._statusCode;
}
}
简单明了。ExceptionType 是一个枚举。
该错误很容易解释,但似乎我做对了,因为 Error 类构造函数有一个单一的可选参数
Error(errorMsg?:string)
这是在“超级”事物之后调用的。
我麻木了。
编辑:尝试了评论中的建议,对我不起作用
编辑 2:正如@estus 指出的那样,错误不在此代码中,而是在
class Ei {
constructor(l, n=Ei.now) {
this.SchedulerAction = l,
this.now = n
}
schedule(l, n=0, e) {
return new this.SchedulerAction(this,l).schedule(e, n)
}
}
Ei.now = Date.now ? Date.now : ()=>+new Date;
class Ti extends Ei {
constructor(l, n=Ei.now) {
this.actions = [],
this.active = !1,
this.scheduled = void 0
}
...
}
受影响的行是
this.actions = []
这与我的代码无关。我将在 github 上打开一个问题。
编辑 3:请检查https://github.com/angular/angular-cli/issues/7799#issuecomment-386582136
解决方案
推荐阅读
- java - 如何设置更改的远程文本文件的正确读取点
- python - Python 上的无效语法:“def 方法(self,(x,y)):”
- c++ - 给定的二叉树是有效的 BST 吗?
- java - 如何使用 Lambda 在 S3 存储桶内触发应用程序?
- python - 如何从字典元素中打印特定字符串?
- java - 如何将表单字段值插入数据库
- autodesk-forge - autodesk-forge Photoscene 进度 API - Photoscene 永远不会进步
- java - 在java中将元素添加到两个不同的数组
- javascript - 如何查看文本区域内的结束行字符?
- python - 检查另一个 Python 程序的输出的 Python 程序