首先,我不确定这是 Angular 问题还是 ES6 问题。
在我们的应用程序的一些重构过程中,我们将一个方法提取到另一个文件中,这样做我们犯了以下错误:
export const setDataTypeToColumn = (
row: any,
col: any
) => {
const updates = this.getChanges().updatedTables;
// Some code in here
}
this.getChanges()
是我们在重构之前使用的主文件中的一个方法,但是在这个新文件中它不存在,如所述的箭头函数中也不存在。但是,在调用时setDataTypeToColumn(x, y)
我们没有收到任何控制台错误。应用程序静默失败,更糟糕的是,后续代码最终没有被执行。
只有当我用 try..catch 包围对 setDataType 的调用时,才会出现异常错误:
TypeError: _this.getChanges is not a function
at Object.push../src/app/components/model-structure/validators.ts.exports.setDataTypeToColumn (validators.ts:120)
at SetupComponent.push../src/app/components/model-structure/ .......
有什么方法可以配置我的环境(linter、编译器、角度本身)来捕获这些异常,而不必在整个地方都使用 try/catch 子句向我的代码发送垃圾邮件?
感谢您的回答和我对新手问题的歉意