首页 文章

类型Error.stackTraceLimit 'number'不可分配给类型'(limit: number) => void'

提问于
浏览
1

在Typescript中,特别是在从https://github.com/preboot/angular2-webpack开始的Angular 2的项目中,我得到以下ts解析错误:

// Polyfill.ts (line 13)

Error.stackTraceLimit = Infinity

[ts]类型'number'不能分配给'(limit:number)=> void' . const错误:ErrorConstructor

对我来说没有意义,因为 Error.stackTraceLimit 确实需要一个数字 . 我已尝试使用函数,因为打字稿也说,但随后它崩溃了浏览器 .

有任何想法吗?

Edit 1

与最新的大师合并后,它的工作原理 .

But ,无论出于何种原因我都需要使用Typescript 2.0.0,然后我收到错误:

错误TS2430:接口'NodeBuffer'错误地扩展了接口'Uint8Array' .

为了解决这个问题,我按照https://github.com/typings/typings/issues/554中的说明运行 typings install env~node -SG 来更新节点类型 .

然后我又回到了错误 Error.stackTraceLimit 'number' is not assignable to type '(limit: number) => void'

似乎在打字上缺少一些东西 . 有关于此的任何想法?

1 回答

  • 1

    我建议你更新你的项目 . 如果您使用angular2-webpack作为项目的基础,那么可能值得与master合并 .

    当我查看您链接的github项目中的代码时,第13行与您编写的内容不匹配 .

    Error['stackTraceLimit'] = Infinity;

相关问题