问题描述
我遇到错误
在以下代码中:
export var UserApiClientModule = {
fromConfiguration: (configuration: Configuration) => {
@NgModule({
providers: [
{
provide: BASE_PATH,
useValue: basePath
},
{
provide: Configuration,
useValue: configuration
},
RegistrationApi,
AuthApi,
AccountApi,
ContactsApi,
ContactOrgsApi
],
imports: [
CommonModule,
HttpModule
]
})
class UserApiClient { }
return UserApiClient;
}
}
我怀疑解决方案是以某种方式导出UserApiClient类型,但是由于在函数中声明了该类型,因此我不确定如何执行此操作.
I suspect the solution is to export the type UserApiClient somehow but I'm not sure how to do this since it's declared in a function.
推荐答案
此处的要点是:
并且因为我们返回的某些内容(不是导出的)是内部的,所以有问题.但是我们可以轻松返回其他内容,例如一些通用的界面...或者至少是神奇的 任何
And because we return something, which is not exported, is internal.. there is a problem. But we can easily return something else, e.g. some common interface ... or at least magical any
// change this
export var UserApiClientModule = {
fromConfiguration: (configuration: Configuration) => {
@NgModule({
...
// to that
export var UserApiClientModule = { // below is the change
fromConfiguration: (configuration: Configuration) : any => {
@NgModule({
...
我宁愿声明一些通用接口 IHaveDynamicData
...实际上与此处所示的类似情况如何使用/创建动态模板以使用Angular 2.0编译动态组件?
I would prefer to declare some common interface IHaveDynamicData
... as in fact in similar case shown here How can I use/create dynamic template to compile dynamic Component with Angular 2.0?
这篇关于导出返回类的函数时出错:导出的变量具有或正在使用私有名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!