【发布时间】: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