【问题标题】:Wrong jasmine typings in Angular 8/9Angular 8/9 中错误的茉莉花类型
【发布时间】:2020-04-30 15:56:18
【问题描述】:

我创建了一个新的空白 angular 9 项目 (ng new my-app)。然后运行: npm install 并仅更改此:

我添加了 .then() 作为 Visual Studio 代码类型报告,期望匹配器返回 Promise

运行npm test -> ng test后,我得到:

ERROR in src/app/app.component.spec.ts:26:41 - error TS2339: Property 'then' does not exist on type 'boolean'.

26     expect(app.title).toEqual('my-app').then(() => { });
                                           ~~~~

所以我从 package.json 中删除了 @types/jasminewd2 并期望匹配器是同步方法,它们不返回承诺,而是布尔值。一切正常。

我在这里错过了什么?有没有其他人有这个问题。这是开箱即用的,我的意思是默认设置。

【问题讨论】:

  • 不要让 IDE 影响您的 packge.json,因为这意味着其他人在另一个 IDE 中使用您的代码可能会发生重大更改。您应该查看添加到 VSCODE 的扩展,它们可能是问题的根源。 VSCode 运行你的ng test script 但不会影响它,所以你最好忽略它。

标签: angular jasmine typescript-typings


【解决方案1】:

这实际上是一个已知的错误,Angular cli 团队已经解决了:

https://github.com/angular/angular-cli/issues/17493

【讨论】:

    猜你喜欢
    • 2023-03-23
    • 1970-01-01
    • 2017-01-15
    • 1970-01-01
    • 2014-12-12
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多