Skip to content

Commit

Permalink
fix(router): correct type of nextState parameter in canDeactivate (#4…
Browse files Browse the repository at this point in the history
…8038)

Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined

Fixes #47153

PR Close #48038
  • Loading branch information
JeanMeche authored and dylhunn committed Nov 17, 2022
1 parent b42ff80 commit e4309d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions goldens/public-api/router/index.md
Expand Up @@ -133,11 +133,11 @@ export type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSn
// @public
export interface CanDeactivate<T> {
// (undocumented)
canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
}

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

// @public
export interface CanLoad {
Expand Down
6 changes: 3 additions & 3 deletions packages/router/src/models.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

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

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

/**
Expand Down

0 comments on commit e4309d5

Please sign in to comment.