refactor: remove extra typescript dependency (#28220)

This commit is contained in:
Liam DeBeasi
2023-09-26 09:01:53 -04:00
committed by GitHub
parent 0b7f6cf573
commit d0d9e35c37
10 changed files with 320 additions and 237 deletions

View File

@ -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;

View File

@ -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;