代码之家  ›  专栏  ›  技术社区  ›  Stepan Suvorov bolelamx

“NgElementConstructor<unknown>”类型的参数不能分配给“CustomElementConstructor”类型的参数

  •  5
  • Stepan Suvorov bolelamx  · 技术社区  · 6 年前

    我在VSCode(1.44.0-insider)中得到一个奇怪的警告,在创建角度元素时使用Angular9:

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

    类型 helloElement 不接受,并显示来自typescript的错误消息:

    “NgElementConstructor”类型的参数不能分配给“CustomElementConstructor”类型的参数

    0 回复  |  直到 6 年前
        1
  •  9
  •   drfrontend 1    6 年前

    似乎在下一个版本中会得到修复: https://github.com/angular/angular/pull/35864

    ng update @angular/core --next 
    
    推荐文章