You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
I am trying to use the RoutableComponent* interfaces, but the typings of canActivate and activate seem slightly incomplete.
exportabstractclassMyViewModelimplementsRoutableComponentCanActivate{asynccanActivate(routeParams: any,routeConfig: RouteConfig){try{constredirect=this.getRedirect();if(redirect)returnredirect;// ... other code returntrue;}catch(err){returnfalse;}}// ... other code}
This causes an error:
Error TS2416 (TS) Property 'canActivate' in type 'MyViewModel' is not assignable to the same property in base type 'RoutableComponentCanActivate'.
Type '(routeParams: any, routeConfig: RouteConfig) => Promise<boolean | NavigationCommand>' is not assignable to type '(params: any, routeConfig: RouteConfig, navigationInstruction: NavigationInstruction) => boolean | Promise<boolean> | PromiseLike<boolean> | NavigationCommand | Promise<...> | PromiseLike<...>'.
Type 'Promise<boolean | NavigationCommand>' is not assignable to type 'boolean | Promise<boolean> | PromiseLike<boolean> | NavigationCommand | Promise<NavigationCommand> | PromiseLike<...>'.
Type 'Promise<boolean | NavigationCommand>' is not assignable to type 'Promise<boolean>'.
Type 'boolean | NavigationCommand' is not assignable to type 'boolean'.
Type 'NavigationCommand' is not assignable to type 'boolean'. C:\DEV\HSE\src\Softcare.HSE.Web\tsconfig.json
Indeed, the type of the function is Promise<boolean | NavigationCommand> which is missing from the declaration.
Expected/desired behavior:
The page works correctly, so I think just adding Promise<boolean | NavigationCommand> (and possibly its analogous PromiseLike) would solve this problem.
This would however bloat the return type, which can be solved by extracting an extra type definition like MaybePromiseOrPromiseLike<T>. Promise already satisfies PromiseLike, so it might be able to be skipped.
The text was updated successfully, but these errors were encountered:
I'm submitting a bug report
Library Version:
1.7.1
Language:
TypeScript 4.9
Current behavior:
I am trying to use the
RoutableComponent*
interfaces, but the typings ofcanActivate
andactivate
seem slightly incomplete.This causes an error:
Indeed, the type of the function is
Promise<boolean | NavigationCommand>
which is missing from the declaration.Expected/desired behavior:
The page works correctly, so I think just adding
Promise<boolean | NavigationCommand>
(and possibly its analogousPromiseLike
) would solve this problem.This would however bloat the return type, which can be solved by extracting an extra type definition like
MaybePromiseOrPromiseLike<T>
.Promise
already satisfiesPromiseLike
, so it might be able to be skipped.The text was updated successfully, but these errors were encountered: