Issue NextCompletionResult is not assignable to type Next

Hi everyone, I’m currently moving my project to the current version on Aurelia and have been confronted with this error messages.

TS2322: Type ‘Promise<NextCompletionResult>’ is not assignable to type ‘Promise<Next>’.

TS2322: Type ‘Promise<NextCompletionResult>’ is not assignable to type ‘Promise<Next>’.
Type ‘NextCompletionResult’ is missing the following properties from type ‘Next’: complete, cancel, reject

This is the code

private checkAndNavigateForAuthorisedUser(navigationInstruction: NavigationInstruction, next: Next): Promise {
let self: AuthorizationInterceptor = this;
let loginRoute: string = this.baseConfig.loginRoute;
let postLoginRoute: string = this.baseConfig.loginRedirect;

  return this.authorizationService.readUserProfile()
  	.then((userProfile: UserProfile): Promise<Next> => {
  		let isRoleAllowed: boolean = self.checkIfUserHasAllowedRoles(navigationInstruction, userProfile);

  		if (!isRoleAllowed) {
  			return next.cancel(new Redirect(postLoginRoute)); // redirect to Home Page
  		} else {
  			let isLoginRoute: boolean = navigationInstruction.getAllInstructions()
  											.some((instruction: NavigationInstruction) => instruction.fragment === loginRoute);
  			if (isLoginRoute) { // Is Logged-in User trying to access Login URL?
  				return next.cancel(new Redirect(postLoginRoute)); // redirect to Home Page
  			}
  		}

  		return next();
  	});

}

Anyone have any idea why, pop this up now?
Thank you.

1 Like

I am not TS user, but I noticed the current doc uses type Promise<any>.

https://aurelia.io/docs/routing/configuration#pipelines

1 Like