Преглед на файлове

refactor: added types to various typescript files to fix errors

Kristian Vos преди 2 години
родител
ревизия
4e1bf1ed5d

+ 4 - 0
frontend/src/classes/ListenerHandler.class.ts

@@ -1,4 +1,8 @@
 export default class ListenerHandler extends EventTarget {
+	listeners: {
+		[name: string]: Array<{ cb: (event: any) => void, options: { replaceable: boolean } }>
+	}
+
 	constructor() {
 		super();
 		this.listeners = {};

+ 2 - 2
frontend/src/store/modules/user.ts

@@ -100,7 +100,7 @@ const modules = {
 						.catch(err => reject(new Error(err.message)));
 				}),
 			logout: () =>
-				new Promise((resolve, reject) => {
+				new Promise<void>((resolve, reject) => {
 					auth.logout()
 						.then(() => resolve())
 						.catch(() => reject());
@@ -133,7 +133,7 @@ const modules = {
 
 										return resolve(user);
 									}
-									return resolve();
+									return resolve(null);
 								}
 							);
 						} else {

+ 1 - 0
frontend/src/types/global.d.ts

@@ -1,5 +1,6 @@
 declare global {
     var lofig: any;
+    var stationInterval: number;
 }
 
 export { };

+ 2 - 2
frontend/src/utils.ts

@@ -4,8 +4,8 @@ export default {
 			.map(b =>
 				b
 					? Math.floor((1 + Math.random()) * 0x10000)
-							.toString(16)
-							.substring(1)
+						.toString(16)
+						.substring(1)
 					: "-"
 			)
 			.join("");

+ 1 - 1
frontend/src/vuex_helpers.ts

@@ -4,7 +4,7 @@ const mapModalState = (namespace, map) => {
 	const modalState = {};
 	// console.log("MAP MODAL STATE", namespace);
 
-	Object.entries(map).forEach(([mapKey, mapValue]) => {
+	Object.entries(map).forEach(([mapKey, mapValue]: [string, (value: object) => void]) => {
 		modalState[mapKey] = function func() {
 			// console.log(
 			// 	321,

+ 2 - 0
frontend/src/ws.ts

@@ -78,6 +78,8 @@ export default {
 			this.socket.dispatch(...args);
 
 		class CustomWebSocket extends WebSocket {
+			dispatcher: ListenerHandler;
+
 			constructor() {
 				super(url);
 				this.dispatcher = new ListenerHandler();