SuperAPI AI 工具集

migrate

通用与其它

查看项目

更新于 10-16 03:05

技能介绍

用途:把 Angular 组件、指令或服务迁移到 Angular 22+ 的 signal 写法。若未提供参数,需先询问组件路径或文件夹。

主要能力:@Input() 转 input()/input.required(),带 setter 的输入转 input()+linkedSignal()(或仅用于 DOM 副作用的 effect()),@Input()+@Output() 成对转 model(),@Output() 转 output(),布尔与数字输入加 booleanAttribute/numberAttribute 转换;@HostBinding/@HostListener 转 host 对象;@ViewChild 等查询转 viewChild()/viewChildren()/contentChild()/contentChildren();*ngIf/*ngFor/*ngSwitch 转 @if/@for(需 track)/@switch;局部状态 BehaviorSubject 转 signal(),combineLatest 转 computed(),仅触发副作用的 Subject 转 effect();CssClassBuilder 转 computed() 类名;DestroyedService 转 DestroyRef+takeUntilDestroyed();移除 standalone: true 与 effect() 的 allowSignalWrites;弃用模块类转单独导入;并按 ESLint 成员顺序整理。

不迁移:HTTP、WebSocket、定时器等异步 RxJS 流,含复杂操作符的 BehaviorSubject,无响应式消费者的普通属性,以及仅用于内部记账的标记。迁移为可选建议,需用户决定范围。

使用方式:先分析目标路径下所有 .ts 与 .html 文件,输出结构化迁移计划(受影响文件、输入输出、宿主绑定、模板、状态管理、跳过项、测试与文档更新、破坏性变更),等待批准后再执行;执行后运行 yarn format、nx run <library>:build、nx run <library>:lint、nx run <library>:test --testfile=<spec-file> --skip-nx-cache 并报告结果。

限制:仅针对 Angular 22+ 迁移场景;具体命令中的库名与测试文件需按项目替换;资料未提供收费、平台与效果信息。