类型为“ NgElementConstructor< unknown>”的参数不可分配给'CustomElementConstructor'类型的参数 [英] Argument of type 'NgElementConstructor<unknown>' is not assignable to parameter of type 'CustomElementConstructor'

查看:96
本文介绍了类型为“ NgElementConstructor< unknown>”的参数不可分配给'CustomElementConstructor'类型的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Angular9创建Angular Elements时,我在VSCode(1.44.0-insider)中收到一个奇怪的警告:

I'm getting a strange warning in VSCode( 1.44.0-insider ) with Angular9 in creating Angular Elements:

export class AppModule { 
  constructor(private injector: Injector) {
    const helloElement = createCustomElement(HelloComponent, {injector});
    customElements.define('my-hello', helloElement);
  }
  ngDoBootstrap() {}
}

类型 helloElement 不会收到来自打字稿的错误消息:

type of helloElement is not accepted with an error message from typescript:


类型为' NgElementConstructor'不可分配给'CustomElementConstructor'类型的参数

Argument of type 'NgElementConstructor' is not assignable to parameter of type 'CustomElementConstructor'


推荐答案

已在下一个版本中修复: https://github.com/angular/angular/pull/35864

It seems it will be fixed with the next release: https://github.com/angular/angular/pull/35864

您已经可以通过更新到下一个版本(9.1.0-next.4)对其项目进行测试。

You can already test it for your project by updating to the next release (9.1.0-next.4).

ng update @angular/core --next 

这篇关于类型为“ NgElementConstructor< unknown>”的参数不可分配给'CustomElementConstructor'类型的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆