You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular13升级至14后ng-circle-progress报TS2707错误求助

解决Angular 14升级后ng-circle-progress的TS2707错误

问题根源

这个错误是因为Angular 14调整了ComponentDeclaration泛型的参数要求(需要7-8个参数),而你当前使用的ng-circle-progress版本未适配Angular 14的类型定义规范。

可行解决方案

1. 安装适配Angular 14的库版本

首先卸载旧版本,重新安装支持Angular 14的最新版:

npm uninstall ng-circle-progress
npm install ng-circle-progress@latest

如果最新版仍不兼容,可查看该库的发布日志,找到明确标注支持Angular 14的版本号进行安装(例如假设兼容版本为2.1.0):

npm install ng-circle-progress@2.1.0

2. 同步TypeScript版本

Angular 14要求TypeScript版本为4.6.x及以上,确保项目TypeScript版本符合要求:

  • 查看当前版本:tsc -v
  • 版本过低则执行更新:
npm install typescript@~4.6.4 --save-dev

3. 临时修复类型定义(不推荐长期使用)

若暂时找不到兼容版本,可手动修改报错的类型文件:

  • 打开node_modules/ng-circle-progress/lib/ng-circle-progress-component.d.ts
  • 找到ComponentDeclaration的泛型声明,补充缺失的参数(通常添加null, null作为第7、8个参数),示例:
    原代码:
    declare const _NgCircleProgressComponent: ComponentDeclaration<...>;
    
    修改后:
    declare const _NgCircleProgressComponent: ComponentDeclaration<..., null, null>;
    
    注意:此修改会在下次执行npm install时被覆盖,仅作为临时应急方案。

4. 清理缓存并重建项目

执行以下命令清理依赖缓存并重新构建:

rm -rf node_modules package-lock.json
npm install
ng serve --clear-cache

内容的提问来源于stack exchange,提问作者Shilpi Jaiswal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 13:35:22