openfoodfacts / openfoodfacts-explorer

An alternative frontend for OpenFoodFacts, made with SvelteKit
https://openfoodfacts-explorer.vercel.app/
GNU Affero General Public License v3.0
25 stars 50 forks source link

chore: `pnpm check` shows errors #300

Closed swastikCommits closed 4 weeks ago

swastikCommits commented 1 month ago

What

svelte-check shows 9 errors in pnpm check

ASUS@DESKTOP-R7CTGHT MINGW64 ~/Desktop/Coding/OSS/openfoodfacts-explorer (main)
pnpm check

> openfoodfacts-sveltekit@0.0.1 check C:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json

====================================
Loading svelte-check in workspace: c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer
Getting Svelte diagnostics...

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\lib\api\prices.ts:51:14
Error: Type '{ set_cookie: true; }' is not assignable to type 'undefined'. 
                return this.client.POST('/api/v1/auth', {
                        params: { query: { set_cookie: true } },
                        body,

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:45:48
Error: Property 'error' does not exist on type 'never'. (ts)
                if (res.error != null) {
                        console.error('Error while logging in', res.error);
                        authStatus = false;

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:71:4
Error: Type 'string' is not assignable to type '"" | "ADP" | "AED" | "AFA" | "AFN" | "ALK" | "ALL" | "AMD" | "ANG" | "AOA" | "AOK" | "AON" | "AOR" | "ARA" | "ARL" | "ARM" | "ARP" | "ARS" | "ATS" | "AUD" | "AWG" | "AZM" | "AZN" | "BAD" | ... 283 more ... | undefined'. (ts)
                        price: newPrice.value,
                        currency: newPrice.currency,
                        // we only need the date, not the time

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:81:54
Error: Property 'error' does not exist on type 'never'. (ts)
                if (res.error != null) {
                        console.error('Error while submitting price', res.error);
                } else {

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:84:11
Error: Property 'items' does not exist on type '{ count: number; next?: string | null | undefined; previous?: string | null | undefined; results: { readonly id: number; product_id: number; location_id: number; proof_id: number; product: { readonly id: number; ... 22 more ...; readonly updated: string; }; ... 21 more ...; readonly updated: string; }[]; }'. (ts)
                        console.debug('Submitted price', res.data);
                        prices.items.push(res.data);
                        invalidateAll();

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:93:30
Error: Property 'size' does not exist on type '{ count: number; next?: string | null | undefined; previous?: string | null | undefined; results: { readonly id: number; product_id: number; location_id: number; proof_id: number; product: { readonly id: number; ... 22 more ...; readonly updated: string; }; ... 21 more ...; readonly updated: string; }[]; }'. (ts)
                <span class="font-bold">
                        Prices: ({Math.min(prices.size ?? 0, prices.total ?? 0)}/{prices.total})
                </span>

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:93:48
Error: Property 'total' does not exist on type '{ count: number; next?: string | null | undefined; previous?: string | null | undefined; results: { readonly id: number; product_id: number; location_id: number; proof_id: number; product: { readonly id: number; ... 22 more ...; readonly updated: string; }; ... 21 more ...; readonly updated: string; }[]; }'. (ts)
                <span class="font-bold">
                        Prices: ({Math.min(prices.size ?? 0, prices.total ?? 0)}/{prices.total})
                </span>

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:93:69
Error: Property 'total' does not exist on type '{ count: number; next?: string | null | undefined; previous?: string | null | undefined; results: { readonly id: number; product_id: number; location_id: number; proof_id: number; product: { readonly id: number; ... 22 more ...; readonly updated: string; }; ... 21 more ...; readonly updated: string; }[]; }'. (ts)
                <span class="font-bold">
                        Prices: ({Math.min(prices.size ?? 0, prices.total ?? 0)}/{prices.total})
                </span>

c:\Users\ASUS\Desktop\Coding\OSS\openfoodfacts-explorer\src\routes\products\[barcode]\Prices.svelte:104:19
Error: Property 'items' does not exist on type '{ count: number; next?: string | null | undefined; previous?: string | null | undefined; results: { readonly id: number; product_id: number; location_id: number; proof_id: number; product: { readonly id: number; ... 22 more ...; readonly updated: string; }; ... 21 more ...; readonly updated: string; }[]; }'. (ts)
                        <tbody>
                                {#each prices.items as price}
                                        <tr>

====================================
svelte-check found 9 errors and 0 warnings in 2 files
 ELIFECYCLE  Command failed with exit code 1.

Steps to reproduce the behavior:

  1. Go to terminal of your code editor
  2. Run pnpm check
  3. It will show 9 errors

Expected behavior

There should not exist any error

Platform (Desktop, Mobile, Hunger Games)

swastikCommits commented 1 month ago

I am currently working on it.