ERROR in Error encountered resolving symbol values statically WITH functions exported.
OS?
W10
Versions.
angular-cli: 1.0.0-beta.24 node: 6.9.4 os: win32 x64 @angular/common: 2.4.3 @angular/compiler: 2.4.3 @angular/core: 2.4.3 @angular/forms: 2.4.3 @angular/http: 2.4.3 @angular/platform-browser: 2.4.3 @angular/platform-browser-dynamic: 2.4.3 @angular/platform-server: 2.4.3 @angular/router: 3.4.3 @angular/compiler-cli: 2.4.3
Repro steps.
Consider following module:
export function angularHttpFactory(backend: XHRBackend, defaultOptions: RequestOptions): Http {
return new Http(backend, defaultOptions);
}
export function authHttpFactory(auth: Auth, backend: XHRBackend, defaultOptions: RequestOptions): AuthHttp {
return new AuthHttp(auth, backend, defaultOptions);
}
@NgModule({
declarations: [LoginLoaderComponent],
imports: [CommonModule, HttpModule, Ng2Webstorage],
exports: [LoginLoaderComponent]
})
export class AuthModule {
static forRoot(authConfig: AuthConfig): ModuleWithProviders {
return {
ngModule: AuthModule,
providers: [
{ provide: AUTH_CONFIG, useValue: authConfig },
{ provide: ANGULAR_HTTP, useFactory: angularHttpFactory, deps: [XHRBackend, RequestOptions] },
Auth,
{ provide: Http, useFactory: authHttpFactory , deps: [Auth, XHRBackend, RequestOptions] },
AuthUser
]
};
}
static forChild(): ModuleWithProviders {
return {
ngModule: AuthModule
};
}
}
The log given by the failure.
ERROR in Error encountered resolving symbol values statically. Calling function 'AuthModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/Users/jacek_dauth3h/Documents/dev/action-center-web-app/src/app/app.module.ts, resolving symbol AppModule in C:/Users/jacek_dauth3h/Documents/dev/action-center-web-app/src/app/app.module.ts
@serhiisol the error of "ERROR in SVGIconModule is not an NgModule" is not tied to the problem stated in this issue. Id suggest looking through the other issues and if you can't find it create a new one
it's actually produced by the same code analyzer
@serhiisol it is, but the subject of this issues says explicitly what it is about. it is not about all problems related to code analyzer, but about the specific problem: resolving symbol values statically WITH functions exported.
@deebloo it turns out, the same issue occurs when using aot compiler without angular CLI. saying that i'm going to continue the discussion on https://github.com/angular/angular/issues/13892
Thanks for help, i cannot make the repo or the used packages public since they are property of the client.
No worries. Hope you get it worked out!
@laPlacek these errors produced by analyzer, look at the code of aot compiler in @angular/compiler
Closing as the (original) issue seems to be a static analysis one as per https://github.com/angular/angular-cli/issues/3967#issuecomment-272480733.
@filipesilva could you explain how to disable static analysis without AOT? My App code is not ready for AOT and CLI fails to compile it despite the fact that I didn't turn on AOT
@serhiisol there is no way to disable it currently. Static analysis is always performed on the code.
@filipesilva In angular team, did you even planned to give that option? just for curiosity
There's no plans to add that option in the CLI that I know of. @hansl can you weigh in?
The Angular documentation still actively promotes the use of static methods in decorators, so no surprise it's so widely used. Is there a (simple) work-around to import ModuleWithProviders into application modules (or modules in general)?
https://angular.io/docs/ts/latest/guide/ngmodule.html#!#core-for-root
@Cogitaria you're right. If that approach has problems with AOT we shouldn't be promoting it in the docs.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.