Angular 5: Can't resolve all parameters for component
It turned out that the reason for this error was an incorrect import of polyfills.ts
. Previously I ejected my cli app and removed polyfills entry point from my webpack config. After that I imported them in my main.ts
. But I imported polyfills after I imported AppModule
. After I moved import './polyfills.ts'
statement to the top of the file the error disappeared.
Another option for fixing this error is moving to AOT compilation:
module: {
rules: [
...
{
"test": /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
"use": [
"@ngtools/webpack"
]
}
]
}
plugins: [
...
new AngularCompilerPlugin({
mainPath: 'main.ts',
platform: PLATFORM.Browser,
hostReplacementPaths: {
'environments/environment.ts': 'environments/environment.ts'
},
sourceMap: true,
tsConfigPath: 'src/app/tsconfig.json',
skipCodeGeneration: false // this line is responsible for AOT
})
]
If you use AOT compilation instead JIT you won't need emitDecoratorMetadata
in your tsconfig
.