【问题标题】:Type Error.stackTraceLimit 'number' is not assignable to type '(limit: number) => void'类型 Error.stackTraceLimit 'number' 不可分配给类型 '(limit: number) => void'
【发布时间】:2017-01-05 08:59:52
【问题描述】:

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

// Polyfill.ts (line 13)

Error.stackTraceLimit = Infinity

[ts] 类型 'number' 不可分配给类型 '(limit: number) => 空白'。常量错误:ErrorConstructor

对我来说没有意义,因为Error.stackTraceLimit 确实需要一个数字。我也尝试过使用打字稿所说的功能,但随后它会使浏览器崩溃。

有什么想法吗?

编辑 1

与最新的master合并后,就可以了。

但是,无论出于何种原因,我都需要使用 Typescript 2.0.0,然后出现错误:

错误 TS2430:接口“NodeBuffer”错误地扩展了接口“Uint8Array”。

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

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

似乎打字上缺少一些东西。对此有何想法?

【问题讨论】:

    标签: angular typescript


    【解决方案1】:

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

    当我查看你链接的 github 项目中的代码时,第 13 行与你写的不匹配。

    Error['stackTraceLimit'] = Infinity;

    【讨论】:

    • 这是一个玩转的剩余部分,但实际上它与使用点符号相同。我会试试你的更新建议。
    • 好的,你提到的我已经试过了。我想这与打字稿版本有关,请参阅编辑后的问题@DylanMeeus
    猜你喜欢
    • 2021-12-05
    • 2020-08-07
    • 1970-01-01
    • 2021-09-18
    • 2022-01-16
    • 2021-11-28
    • 1970-01-01
    • 2023-01-22
    • 2018-08-15
    相关资源
    最近更新 更多