Error in module.ngFactory. Calling function 'document', function calls are not supported
OS?
windows 10
Versions.
@angular/cli: 1.0.0-beta.31 node: 7.1.0 os: win32 x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/compiler-cli: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2.4.7 @angular/platform-browser: 2.4.7 @angular/platform-browser-dynamic: 2.4.7 @angular/platform-server: 2.4.7 @angular/router: 3.0.0 @angular/upgrade: 2.4.7 @ngtools/webpack: 1.2.9
Repro steps.
Webpack aot plugin was used to compile the angular app.
The intention of this part code is to retrieve server-side state stored in a hidden element by using document.querySelector
In module.ts,
import { StoreModule } from '@ngrx/store';
import { getRehydratedState } from './rehydratedState';
@NgModule({
imports:[
StoreModule.provideStore(reducer, getRehydratedState('RehydratedState') )
]
})
in rehydratedState.ts
export function getRehydratedState(selector: string): string {
return document.querySelector(selector).textContent;
}
The log given by the failure.
Error encountered resolving symbol values statically. Calling function 'document', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol getRehydratedState...
Mention any other details that might be useful.
Seems like angular static analyzer doesn't like document
you can't have function calls in your decorators. Decorators need to be static.
What @deebloo said. The Angular annotations are supposed to be fully static.
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.