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

Ste*_*rov 9 visual-studio-code angular angular-elements

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

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

类型helloElement不接受,并带有来自打字稿的错误消息:

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

drf*_*d 1 9

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

您已经可以通过更新到下一个版本 (9.1.0-next.4) 来为您的项目测试它。

ng update @angular/core --next 
Run Code Online (Sandbox Code Playgroud)