From 55229252d750a6a00a26bade28b802f1f02e786b Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 21 Feb 2022 17:37:30 +0530 Subject: [PATCH] Type allowsChild --- src/domain/navigation/Navigation.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/domain/navigation/Navigation.ts b/src/domain/navigation/Navigation.ts index dfd69bd1..b3b79a89 100644 --- a/src/domain/navigation/Navigation.ts +++ b/src/domain/navigation/Navigation.ts @@ -15,7 +15,6 @@ limitations under the License. */ import {BaseObservableValue, ObservableValue} from "../../observable/ObservableValue"; -import type {allowsChild as AllowsChild} from "./index.js"; type SegmentType = { "login": true; @@ -34,14 +33,15 @@ type SegmentType = { "member": string; }; +type AllowsChild = (parent: Segment | undefined, child: Segment) => boolean; export class Navigation { - private readonly _allowsChild: AllowsChild; + private readonly _allowsChild: AllowsChild; private _path: Path; private readonly _observables: Map> = new Map(); private readonly _pathObservable: ObservableValue>; - constructor(allowsChild: AllowsChild) { + constructor(allowsChild: AllowsChild) { this._allowsChild = allowsChild; this._path = new Path([], allowsChild); this._pathObservable = new ObservableValue(this._path); @@ -140,9 +140,9 @@ export class Segment { class Path { private readonly _segments: Segment[]; - private readonly _allowsChild: AllowsChild; + private readonly _allowsChild: AllowsChild; - constructor(segments: Segment[] = [], allowsChild: AllowsChild) { + constructor(segments: Segment[] = [], allowsChild: AllowsChild) { this._segments = segments; this._allowsChild = allowsChild; } @@ -237,13 +237,13 @@ export function tests() { return new Navigation((parent, {type}) => { switch (parent?.type) { case undefined: - return type === "1" || "2"; + return type === "1" || type === "2"; case "1": return type === "1.1"; case "1.1": return type === "1.1.1"; case "2": - return type === "2.1" || "2.2"; + return type === "2.1" || type === "2.2"; default: return false; }