Effort to transition to TypeScript

Remove commit warnings
This commit is contained in:
Michał Gdula 2024-05-02 19:10:21 +01:00
parent 4f0ecd33e4
commit 1486c1b70a
18 changed files with 93 additions and 87 deletions

View file

@ -1,4 +1,5 @@
import Items from '%/lib/test-data.js';
import type { Item } from './types';
import TestData from './test-data';
let cache = {
@ -7,8 +8,10 @@ let cache = {
};
// @ts-ignore
async function fakeDelay(timeout: number = 1000) {
await new Promise(resolve => setTimeout(resolve, timeout));
// @ts-ignore
await new Promise((resolve: TimerHandler) => setTimeout(resolve, timeout));
}
@ -31,7 +34,7 @@ export async function getPopularToday() {
return cache.popular_today;
}
const data = Items;
const data = TestData;
cache.popular_today = data;
await fakeDelay(200)
return data;
@ -42,7 +45,7 @@ export async function getMenuItems() {
const data = [
{
name: "Main Menu",
items: Items,
items: TestData,
},
{
name: "Breakfast",
@ -50,7 +53,7 @@ export async function getMenuItems() {
},
{
name: "Seasonal",
items: Items,
items: TestData,
},
];
await fakeDelay(20)
@ -61,7 +64,7 @@ export async function getMenuItems() {
export async function getItemsByUUID(items: string[]) {
let data = [];
Items.forEach((itemInDatabase) => {
TestData.forEach((itemInDatabase: Item) => {
items.forEach((itemInRequest) => {
if (itemInDatabase.uuid === itemInRequest) {
data.push(itemInDatabase);
@ -94,10 +97,10 @@ export async function postContactEmail(name: string, email: string, message: str
await fakeDelay(200)
if (!name) {
throw new Error("Namey missing");
throw new Error("Name missing");
}
if (!email) {
throw new Error("Emaily missing");
throw new Error("Email missing");
}
if (!message) {
throw new Error("Message missing");