mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
refactor: remove extra typescript dependency (#28220)
This commit is contained in:
@ -312,6 +312,7 @@ export class Router implements ComponentInterface {
|
||||
const routes = readRoutes(this.el);
|
||||
|
||||
const fromChain = findChainForSegments(from, routes);
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
||||
const beforeLeaveHook = fromChain && fromChain[fromChain.length - 1].beforeLeave;
|
||||
|
||||
const canLeave = beforeLeaveHook ? await beforeLeaveHook() : true;
|
||||
@ -320,6 +321,7 @@ export class Router implements ComponentInterface {
|
||||
}
|
||||
|
||||
const toChain = findChainForSegments(to, routes);
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
||||
const beforeEnterHook = toChain && toChain[toChain.length - 1].beforeEnter;
|
||||
|
||||
return beforeEnterHook ? beforeEnterHook() : true;
|
||||
|
||||
@ -48,6 +48,7 @@ export const chainToSegments = (chain: RouteChain): string[] | null => {
|
||||
for (const route of chain) {
|
||||
for (const segment of route.segments) {
|
||||
if (segment[0] === ':') {
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
||||
const param = route.params && route.params[segment.slice(1)];
|
||||
if (!param) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user