Browse Source

fix typescript warning

tripeur 4 years ago
parent
commit
271825d218
4 changed files with 13 additions and 11 deletions
  1. 0 1
      src/models/Creneau.ts
  2. 2 2
      src/utils/Compression.ts
  3. 6 6
      src/utils/Toast.ts
  4. 5 2
      src/utils/csv.ts

+ 0 - 1
src/models/Creneau.ts

@@ -1,6 +1,5 @@
 import dayjs from "dayjs";
 import { Event, EventJSON } from "jc-timeline";
-import Benevole from "./Benevole";
 import { MealSlot, TimeslotRaw } from "./SolverInput";
 
 export interface ICreneau {

+ 2 - 2
src/utils/Compression.ts

@@ -42,7 +42,7 @@ function getBase64Code(charCode: number): number {
   return code;
 }
 
-export function bytesToBase64(bytes: Uint8Array) {
+export function bytesToBase64(bytes: Uint8Array): string {
   let result = "",
     i: number;
   const l = bytes.length;
@@ -68,7 +68,7 @@ export function bytesToBase64(bytes: Uint8Array) {
   return result;
 }
 
-export function base64ToBytes(str: string) {
+export function base64ToBytes(str: string): Uint8Array {
   if (str.length % 4 !== 0) {
     throw new Error("Unable to parse base64 string.");
   }

+ 6 - 6
src/utils/Toast.ts

@@ -25,7 +25,7 @@ export class Toast {
   startTime: number;
   startingPosX: number;
 
-  get activationDistance() {
+  get activationDistance(): number {
     return this.element.offsetWidth * this.options.activationPercent;
   }
   constructor(options: Partial<ToastOptions>) {
@@ -96,7 +96,7 @@ export class Toast {
     }, 10);
     Toast._toasts.push(this);
   }
-  update() {
+  update(): void {
     const ellapsed = Date.now() - this.startTime;
     if (this.options && ellapsed < this.options.displayLength) {
       this.element.style.setProperty(
@@ -108,14 +108,14 @@ export class Toast {
       this.dismiss();
     }
   }
-  _getposX(e: MouseEvent | TouchEvent) {
+  _getposX(e: MouseEvent | TouchEvent): number {
     if (e instanceof MouseEvent) {
       return e.clientX;
     } else {
       return e.touches[0].clientX;
     }
   }
-  dismiss() {
+  dismiss(): void {
     this.element.style.transition = `all ${this.options.outDuration}ms`;
     this.element.style.marginTop = `-${this.element.offsetHeight}px`;
     this.element.style.opacity = "0";
@@ -128,7 +128,7 @@ export class Toast {
       if (this.options.completeCallback) this.options.completeCallback(this);
     }, this.options.outDuration);
   }
-  static dismissAll() {
+  static dismissAll(): void {
     for (const toastIndex in Toast._toasts) {
       Toast._toasts[toastIndex].dismiss();
     }
@@ -139,7 +139,7 @@ export class Toast {
     document.body.appendChild(container);
     Toast._container = container;
   }
-  static _removeContainer() {
+  static _removeContainer(): void {
     if (Toast._container) {
       document.body.removeChild(Toast._container);
       Toast._container = null;

+ 5 - 2
src/utils/csv.ts

@@ -87,11 +87,14 @@ const parseCSV = function (
   if (!emptyEntry) output.push(currentEntry);
   return output;
 };
-const toObject = function (str: string, options: Partial<csvOptions> = defaultoptions) {
+const toObject = function (
+  str: string,
+  options: Partial<csvOptions> = defaultoptions
+): Array<{ [k: string]: string }> {
   const arr = parseCSV(str, options);
   return ArraytoObject(arr);
 };
-const ArraytoObject = function (arr: Array<Array<string>>) {
+const ArraytoObject = function (arr: Array<Array<string>>): Array<{ [k: string]: string }> {
   const output = [];
   const header = arr[0].map((s) => s.trim());
   for (let i = 1; i < arr.length; i++) {