是否可以使以下代码与AoT兼容?

interface Config {
    someField?: string;
    anotherField?: number;
}

@NgModule({})
export class SomeModule {
    protected static _config: Config;

    public static withConfig(config: Config = {}): ModuleWithProviders {
        // the line below fails AoT compilation
        SomeModule._config = Object.assign({}, { someField: 'defaultValue' }, config);
        return {
            ngModule: SomeModule,
            providers: []
        };
    }
}

必须在主模块中导入 SomeModule.withConfig() ,并且必须在应用程序启动之前同步设置config(用于装饰功能),但是通过AoT编译,它会抛出:

完成Angular编译,启动webpack捆绑 . 错误:静态解析符号值时遇到错误 . 调用函数'SomeModule',不支持函数调用 . 考虑使用对导出函数的引用替换函数或lambda,解析/.../app/app.module.ts中的符号AppModule,解析/../app/app.module.ts中的符号AppModule

有任何想法吗?

编辑:由于评论,这是我在app.module中导入模块的方式:

@NgModule({
    imports: [
        SomeModule.withConfig(), // yeah, just like that or with { someField: '' }
    ]
})
export class AppModule {}