Skip to content

Commit b51929a

Browse files
JeanMechedylhunn
authored andcommitted
fix(router): correct type of nextState parameter in canDeactivate (#48038)
Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined Fixes #47153 PR Close #48038
1 parent 1e561f9 commit b51929a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

goldens/public-api/router/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ export type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSn
133133
// @public
134134
export interface CanDeactivate<T> {
135135
// (undocumented)
136-
canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
136+
canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
137137
}
138138

139139
// @public
140-
export type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
140+
export type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
141141

142142
// @public
143143
export interface CanLoad {

packages/router/src/models.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {EnvironmentInjector, EnvironmentProviders, InjectionToken, NgModuleFactory, Provider, ProviderToken, Type} from '@angular/core';
9+
import {EnvironmentInjector, EnvironmentProviders, InjectionToken, NgModuleFactory, Provider, Type} from '@angular/core';
1010
import {Observable} from 'rxjs';
1111

1212
import {DeprecatedLoadChildren} from './deprecated_load_children';
@@ -851,7 +851,7 @@ export type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, state: Rou
851851
export interface CanDeactivate<T> {
852852
canDeactivate(
853853
component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot,
854-
nextState?: RouterStateSnapshot): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean
854+
nextState: RouterStateSnapshot): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean
855855
|UrlTree;
856856
}
857857

@@ -864,7 +864,7 @@ export interface CanDeactivate<T> {
864864
*/
865865
export type CanDeactivateFn<T> =
866866
(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot,
867-
nextState?: RouterStateSnapshot) =>
867+
nextState: RouterStateSnapshot) =>
868868
Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree;
869869

870870
/**

0 commit comments

Comments
 (0)