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

UpdateController报错:PartialTypeDTO与Service所用Interface冲突求解决方案

问题:使用PartialType实现Admin更新时避免重复定义Interface

CreateAdmin.DTO.ts

CreateAdmin.DTO.ts 代码截图

UpdateAdmin.DTO.ts

该文件通过PartialType继承,使更新Admin时所有字段均为可选。
UpdateAdmin.DTO.ts 代码截图

AdminInterface.ts

AdminInterface.ts 代码截图

admin.controller.ts

这是我的更新控制器,我希望使用PartialType而无需创建第二个Interface(我认为使用两个Interface不合理)。
admin.controller.ts 代码截图

VSCode错误提示

VSCode中显示的错误

现有尝试与诉求

我曾尝试创建第二个Interface,但认为这种方式不合理。目前能想到的方案是为更新(Patch/PUT)端点创建新的Interface,但希望找到更优的解决办法。

Admin.Service.ts

Admin.Service.ts 代码截图

内容的提问来源于stack exchange,提问作者Syed Murtaza Ali Shah

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 22:32:21