期望不正确的智能感知方法
Intesllisense methods for expect incorrect
在 VS-Code 中使用 intellisense 时,它会针对比我正在使用的旧版本的 expect 提供自动完成建议。 API 自从捐赠给 Jest 项目后发生了变化,但由于某种原因,它仍然显示旧方法,但 none 的替换方法,如 toHaveProperty
.
花了很多精力找出我的测试不起作用的原因,但一直无法找到可能的原因的答案。
VS Code 从 NPM 上的 @types
命名空间获取 JavaScript 的类型定义,其中包含自动从 DefinitelyTyped GitHub repository.
中提取的定义文件
在您的情况下,类型定义将来自 @types/expect
package, which specifies in the README that it exposes the files from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/expect。
如果您查看上述文件的时间戳,您会发现它们已经 5 个月没有更新了!这很可能是您问题的根源。
您(或其他人)将需要提交更新的类型定义以使该库的自动类型获取功能正常运行。或者,you can override the type definitions locally or disable the feature altogether.
在 VS-Code 中使用 intellisense 时,它会针对比我正在使用的旧版本的 expect 提供自动完成建议。 API 自从捐赠给 Jest 项目后发生了变化,但由于某种原因,它仍然显示旧方法,但 none 的替换方法,如 toHaveProperty
.
花了很多精力找出我的测试不起作用的原因,但一直无法找到可能的原因的答案。
VS Code 从 NPM 上的 @types
命名空间获取 JavaScript 的类型定义,其中包含自动从 DefinitelyTyped GitHub repository.
在您的情况下,类型定义将来自 @types/expect
package, which specifies in the README that it exposes the files from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/expect。
如果您查看上述文件的时间戳,您会发现它们已经 5 个月没有更新了!这很可能是您问题的根源。
您(或其他人)将需要提交更新的类型定义以使该库的自动类型获取功能正常运行。或者,you can override the type definitions locally or disable the feature altogether.