Angular 隐式获取对象类型的错误索引签名具有';任何';类型

Angular 隐式获取对象类型的错误索引签名具有';任何';类型,angular,Angular,我正在使用Angular版本2.1.0并编写一个服务来动态加载组件 我发现下面有一个错误,如何解决 错误TS7017对象类型的索引签名隐式具有“any”类型。 从'@angular/core'导入{Injectable,ComponentFactoryResolver,ApplicationRef,ElementRef,ViewContainerRef}; 从“../components/blockui/blockui.component”导入{SpinnerComponent}; @可注射(

我正在使用Angular版本2.1.0并编写一个服务来动态加载组件

我发现下面有一个错误,如何解决

错误TS7017对象类型的索引签名隐式具有“any”类型。

从'@angular/core'导入{Injectable,ComponentFactoryResolver,ApplicationRef,ElementRef,ViewContainerRef};
从“../components/blockui/blockui.component”导入{SpinnerComponent};
@可注射()
出口级喷丝板服务{
喷丝头组件:ViewContainerRef;
构造函数(私有componentLoader:ComponentFactoryResolver,私有appRef:ApplicationRef){}
公共启动(){
//这行有错误吗?
让elementRef:elementRef=this.appRef[''u rootComponents'][0]。位置;
返回此.startInside(elementRef,null);
}
公共startInside(elementRef:elementRef,anchorName:string){
让spinnerRef=(!anchorName)?
此.componentLoader.resolveComponentFactory.call(SpinnerComponent,elementRef):
调用(SpinnerComponent、elementRef、anchorName);
spinnerRef.then((compRef:ViewContainerRef)=>{
this.spinnerComp=compRef;
});
}
公众站{
if(本喷丝头公司){
此.喷丝头组件分离();
}
}

}
它告诉您,当您执行
此.appRef[''u rootComponents']
时,它不知道属性的类型,默认情况下假定
任何
,根据tsc配置文件中的设置将其视为错误。请阅读以了解更多详细信息和可能的解决方案。

它告诉您,当您执行
此.appRef['''u rootComponents']
时,它不知道属性的类型,并默认假定
任何
,根据tsc配置文件中的设置,该属性被视为错误。有关更多详细信息和可能的解决方案,请阅读。

它显示为
this.appRef[''u rootComponents'][0]。location
不是
ElementRef
类型,它显示为
this.appRef['u rootComponents'][0]。location
不是
ElementRef