feat(compiler): enabled strict checking of parameters to an @Injectable
(#19412)
Added the compiler options `strictInjectionParameters` that defaults to `false`. If enabled the compiler will report errors for parameters of an `@Injectable` that cannot be determined instead of generating a warning. This is planned to be switched to default to `true` for Angular 6.0.
This commit is contained in:

committed by
Victor Berchet

parent
a75040d0a1
commit
dfb8d21ef4
@ -886,10 +886,10 @@ export class CompileMetadataResolver {
|
||||
dependenciesMetadata.map((dep) => dep ? stringifyType(dep.token) : '?').join(', ');
|
||||
const message =
|
||||
`Can't resolve all parameters for ${stringifyType(typeOrFunc)}: (${depsTokens}).`;
|
||||
if (throwOnUnknownDeps) {
|
||||
if (throwOnUnknownDeps || this._config.strictInjectionParameters) {
|
||||
this._reportError(syntaxError(message), typeOrFunc);
|
||||
} else {
|
||||
this._console.warn(`Warning: ${message} This will become an error in Angular v5.x`);
|
||||
this._console.warn(`Warning: ${message} This will become an error in Angular v6.x`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user