added page name type

This commit is contained in:
Miodec 2023-06-19 21:33:51 +02:00
parent fd48402840
commit 381ee144c5
3 changed files with 16 additions and 5 deletions

View file

@ -4,7 +4,7 @@ interface Options {
}
export default class Page {
public name: string;
public name: MonkeyTypes.PageName;
public element: JQuery;
public pathname: string;
public beforeHide: () => Promise<void>;
@ -12,7 +12,7 @@ export default class Page {
public beforeShow: (options: Options) => Promise<void>;
public afterShow: () => Promise<void>;
constructor(
name: string,
name: MonkeyTypes.PageName,
element: JQuery,
pathname: string,
beforeHide: () => Promise<void>,

View file

@ -1,9 +1,9 @@
let activePage = "loading";
let activePage: MonkeyTypes.PageName = "loading";
export function get(): string {
export function get(): MonkeyTypes.PageName {
return activePage;
}
export function set(active: string): void {
export function set(active: MonkeyTypes.PageName): void {
activePage = active;
}

View file

@ -1,6 +1,17 @@
type typesSeparatedWithHash<T> = T | `${T}#${typesSeparatedWithHash<T>}`;
declare namespace MonkeyTypes {
type PageName =
| "loading"
| "test"
| "settings"
| "about"
| "account"
| "login"
| "profile"
| "profileSearch"
| "404";
type Difficulty = "normal" | "expert" | "master";
type Mode = keyof PersonalBests;