mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(core): correct typing checks when registering destroy hooks (#44087)
Making the typing filtering more explicit allows typescript to properly recognize the presence of the `prototype` property on the provider within the `registerDestroyHooksIfSupported` method. PR Close #44087
This commit is contained in:
committed by
Andrew Scott
parent
e0ae557aee
commit
401b5bf2af
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
import {resolveForwardRef} from '../di/forward_ref';
|
||||
import {ClassProvider, Provider} from '../di/interface/provider';
|
||||
import {ClassProvider, Provider, TypeProvider} from '../di/interface/provider';
|
||||
import {isClassProvider, isTypeProvider, providerToFactory} from '../di/r3_injector';
|
||||
import {assertDefined} from '../util/assert';
|
||||
|
||||
@@ -192,7 +192,7 @@ function registerDestroyHooksIfSupported(
|
||||
indexInFactory?: number) {
|
||||
const providerIsTypeProvider = isTypeProvider(provider);
|
||||
if (providerIsTypeProvider || isClassProvider(provider)) {
|
||||
const prototype = ((provider as ClassProvider).useClass || provider).prototype;
|
||||
const prototype = ((provider as ClassProvider).useClass || provider as TypeProvider).prototype;
|
||||
const ngOnDestroy = prototype.ngOnDestroy;
|
||||
if (ngOnDestroy) {
|
||||
const hooks = tView.destroyHooks || (tView.destroyHooks = []);
|
||||
|
||||
Reference in New Issue
Block a user