From 496372dd30cc7713388aa92e44394f9af6a03d0c Mon Sep 17 00:00:00 2001 From: Jason Aden Date: Tue, 16 Oct 2018 15:54:07 -0700 Subject: [PATCH] fix(router): remove type bludgeoning of context and outlet when running CanDeactivate (#26496) Fixes #18253 PR Close #26496 --- packages/router/src/utils/preactivation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/router/src/utils/preactivation.ts b/packages/router/src/utils/preactivation.ts index 2f56a177aa..3b3dd31d6a 100644 --- a/packages/router/src/utils/preactivation.ts +++ b/packages/router/src/utils/preactivation.ts @@ -121,8 +121,8 @@ function getRouteGuards( } if (shouldRun) { - const outlet = context !.outlet !; - checks.canDeactivateChecks.push(new CanDeactivate(outlet.component, curr)); + const component = context && context.outlet && context.outlet.component || null; + checks.canDeactivateChecks.push(new CanDeactivate(component, curr)); } } else { if (curr) {