diff --git a/front/src/lib/api.ts b/front/src/lib/api.ts index d21492a..af141a9 100644 --- a/front/src/lib/api.ts +++ b/front/src/lib/api.ts @@ -3,14 +3,11 @@ import { type Item, type JSONResponse } from "./types"; const API_URL = "http://127.0.0.1:8080"; export async function getPopularToday(): Promise { - const response = await fetch(`${API_URL}/api/items`); + const response: Response = await fetch(`${API_URL}/api/items`); const { data, error }: JSONResponse = await response.json(); - if (response.ok) { - if (data?.item) { - return data?.item; - } - throw new Error("Failed to fetch popular today"); - } - throw new Error(error); + if (!response.ok) throw new Error(error); + if (!data?.item) throw new Error("Failed to fetch popular today"); + + return data?.item; } diff --git a/front/src/lib/utils.js b/front/src/lib/utils.js deleted file mode 100644 index 726a1f3..0000000 --- a/front/src/lib/utils.js +++ /dev/null @@ -1,6 +0,0 @@ -export function expandOnTyping(element) { - element.oninput = (event) => { - event.target.style.height = ""; // skipcq: JS-W1032 - event.target.style.height = `${event.target.scrollHeight + 2}px`; - }; -} diff --git a/front/src/lib/utils.ts b/front/src/lib/utils.ts new file mode 100644 index 0000000..92ac3e8 --- /dev/null +++ b/front/src/lib/utils.ts @@ -0,0 +1,6 @@ +export function expandOnTyping(element: HTMLTextAreaElement) { + element.oninput = () => { + element.style.height = ""; // skipcq: JS-W1032 + element.style.height = `${element.scrollHeight + 2}px`; + }; +} diff --git a/front/jsconfig.json b/front/tsconfig.json similarity index 86% rename from front/jsconfig.json rename to front/tsconfig.json index 5696a2d..4953d2b 100644 --- a/front/jsconfig.json +++ b/front/tsconfig.json @@ -1,14 +1,15 @@ { "compilerOptions": { "moduleResolution": "bundler", - "target": "ESNext", - "module": "ESNext", + "module": "ES2015", + "target": "ES2017", + "lib": ["ES2017", "DOM"], /** * svelte-preprocess cannot figure out whether you have * a value or a type, so tell TypeScript to enforce using * `import type` instead of `import` for Types. */ - "verbatimModuleSyntax": true, + "verbatimModuleSyntax": false, "isolatedModules": true, "resolveJsonModule": true, /** @@ -22,6 +23,7 @@ * Typecheck JS in `.svelte` and `.js` files by default. * Disable this if you'd like to use dynamic types. */ + "allowJs": true, "checkJs": true }, /**