Switch to tsconfig

Fix changes due to change in target module
This commit is contained in:
Michał 2024-05-15 16:36:29 +01:00
parent 2ef63ac6f6
commit 46b624954c
4 changed files with 16 additions and 17 deletions

View file

@ -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<Item[]> {
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) {
if (!response.ok) throw new Error(error);
if (!data?.item) throw new Error("Failed to fetch popular today");
return data?.item;
}
throw new Error("Failed to fetch popular today");
}
throw new Error(error);
}

View file

@ -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`;
};
}

6
front/src/lib/utils.ts Normal file
View file

@ -0,0 +1,6 @@
export function expandOnTyping(element: HTMLTextAreaElement) {
element.oninput = () => {
element.style.height = ""; // skipcq: JS-W1032
element.style.height = `${element.scrollHeight + 2}px`;
};
}

View file

@ -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
},
/**