typescript - '< 类型的参数>' 不可分配给类型为 'Type< 的参数>'
问题描述
这是我得到的错误。我知道某种类型的参数不匹配,但我无法弄清楚它发生在堆栈的哪个位置。
Argument of type 'ModalUserInfoComponent' is not assignable to
parameter of type 'Type<ModalUserInfoComponent>'.
Type 'ModalUserInfoComponent' is missing the following properties from
type 'Type<ModalUserInfoComponent>': apply, call, bind, prototype, and
5 more.
我已经设置了一个stackblitz来显示这个问题。该功能仅部分有效(我假设未传递必要的表单构建器数据,因为此问题以某种方式阻止了它)。
您会在 stackblitz 中注意到模态仅传回名字和姓氏,其余的都不存在。
还有另一个错误,我很确定它是相关的,但我还没有调查过。
Error: "ExpressionChangedAfterItHasBeenCheckedError: Expression has
changed after it was checked. Previous value: 'form: undefined'.
Current value: 'form: [object Object]'. It seems like the view has been
created after its parent and its children have been dirty checked. Has
it been created in a change detection hook ?"
解决方案
好的——这个问题的修复是:
public contentComponent: Type<ModalVariants>;
代替:
public contentComponent: <ModalVariants>;
这就是我所拥有的。
推荐阅读
- java - Java 如果我有一个 javax.servlet.http.Part 数组,那么一个部分是否总是代表一个文件
- 3d - 如何修复 3D 平台游戏的跳转代码?
- reporting-services - 在 SSRS 文本段落中添加超链接
- powershell - 获取无法将“System.Object []”转换为 Add-PowerBIRow 的参数“DatasetId”所需的类型“System.Guid”
- winapi - postmessage return 传递给系统调用的数据区域太小
- excel - excel - 如果公式条件
- regex - 删除文件中两个字符串匹配项之间的所有内容
- ruby-on-rails - Sidekiq 过去曾将工作排入队列
- android - Flutter android应用程序中的GmsClient错误
- javascript - Javascript SDK V3 -S3:调用 ListObjectsV2Command 时出错