Give defaultt type

This commit is contained in:
RMidhunSuresh 2022-02-22 22:23:52 +05:30
parent f49d580d49
commit 9300347e9b
2 changed files with 4 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import type {Platform} from "../platform/web/Platform";
import type {Clock} from "../platform/web/dom/Clock";
import type {ILogger} from "../logging/types";
import type {Navigation} from "./navigation/Navigation";
import type {SegmentType} from "./navigation/index";
import type {URLRouter} from "./navigation/URLRouter";
type Options<N extends {session: string}> = {
@ -37,7 +38,7 @@ type Options<N extends {session: string}> = {
emitChange?: (params: any) => void
}
export class ViewModel<N extends {session: string}, O extends Options<N> = Options<N>> extends EventEmitter<{change: never}> {
export class ViewModel<N extends {session: string} = SegmentType, O extends Options<N> = Options<N>> extends EventEmitter<{change: never}> {
private disposables?: Disposables;
private _isDisposed = false;
private _options: Readonly<O>;

View File

@ -18,7 +18,7 @@ import {Navigation, Segment} from "./Navigation";
import {URLRouter} from "./URLRouter";
import type {Path, OptionalValue} from "./Navigation";
type SegmentType = {
export type SegmentType = {
"login": true;
"session": string;
"sso": string;
@ -124,7 +124,7 @@ export function addPanelIfNeeded<T extends SegmentType>(navigation: Navigation<T
}
export function parseUrlPath(urlPath: string, currentNavPath: Path<SegmentType>, defaultSessionId?: string): Segment<SegmentType>[] {
// substr(1) to take of initial /
// substring(1) to take of initial /
const parts = urlPath.substring(1).split("/");
const iterator = parts[Symbol.iterator]();
const segments: Segment<SegmentType>[] = [];