fix(core): don't override ngInjectableDef in the decorator if present on the type (#22943)
Previously, @Injectable() would generate an ngInjectableDef on the type it was decorating, even if that type already had a compiled ngInjectableDef, overwriting the compiled version. PR Close #22943
This commit is contained in:

committed by
Matias Niemelä

parent
4f0cae0676
commit
6f0191744c
@ -119,7 +119,8 @@ export const Injectable: InjectableDecorator = makeDecorator(
|
||||
'Injectable', undefined, undefined, undefined,
|
||||
(injectableType: InjectableType<any>,
|
||||
options: {providedIn?: Type<any>| 'root' | null} & InjectableProvider) => {
|
||||
if (options && options.providedIn !== undefined) {
|
||||
if (options && options.providedIn !== undefined &&
|
||||
injectableType.ngInjectableDef === undefined) {
|
||||
injectableType.ngInjectableDef = defineInjectable({
|
||||
providedIn: options.providedIn,
|
||||
factory: convertInjectableProviderToFactory(injectableType, options)
|
||||
|
Reference in New Issue
Block a user