使用 Angular 8 升级到 chart.js@3.x

Uprading to chart.js@3.x with Angular 8

我正在尝试从 chart.js 2.9.4 升级到 chart.js 3.x 以删除大量 moment.js 依赖项。我的应用程序是 运行 angular 8.2.3 和打字稿 3.5.3.

安装后 chart.js@3.x 我在导入包时收到此错误:

node_modules/chart.js/types/utils.d.ts:13:49 - error TS2315: Type 'DeepPartial' is not generic.

13 type _DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };

是否可以使用 angular 8.2.3 升级到 chart.js@3.x? Chart.js 没有说明第 3 版需要更新的 typescript 版本,而且我找不到任何解决方案

感谢您的帮助!

Chart.js 在 Chart.js V3 之前从未支持打字稿。所以它不需要提到它需要更新版本的打字稿,因为它从来不支持它。

Chart.js V3 的每个稳定版本都需要 Typescript V4。也没有支持 typescript V3 的计划,因为它太旧了 git issue.

因此,如果您想将它与 angular 8.2.3 一起使用,您将需要禁用类型检查或自行更新类型,使其与 typescript V3 兼容