Skip to content

Commit 2fde130

Browse files
committed
refactor(@angular/ssr): add workaround for router lastSuccessfulNavigation breaking changing
This workaround is needed to; - Re-enable SSG in ADEV - Re-enable SSR tests in angular/angular main - Make cross-repo updates green again (cherry picked from commit 68f64fc)
1 parent 6a79f9a commit 2fde130

File tree

1 file changed

+9
-1
lines changed
  • packages/angular/ssr/src/utils

1 file changed

+9
-1
lines changed

packages/angular/ssr/src/utils/ng.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ export async function renderAngular(
100100
const envInjector = applicationRef.injector;
101101
const routerIsProvided = !!envInjector.get(ActivatedRoute, null);
102102
const router = envInjector.get(Router);
103-
const lastSuccessfulNavigation = router.lastSuccessfulNavigation;
103+
104+
// TODO(alanagius): Remove the below check when version 21.0.0-next.0 is on NPM
105+
// Workaround for breaking change that landed on angular/angular main too early
106+
// https://github.com/angular/angular/pull/63057
107+
const lastSuccessfulNavigation =
108+
typeof router.lastSuccessfulNavigation === 'function'
109+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
110+
(router as any).lastSuccessfulNavigation()
111+
: router.lastSuccessfulNavigation;
104112

105113
if (!routerIsProvided) {
106114
hasNavigationError = false;

0 commit comments

Comments
 (0)