fix: repair defects surfaced by gating CI on lint and typecheck

`npm run check` reported 15 errors and `npm run lint` 20, all pre-existing, so
neither gate could pass. Fixing them turned up three real bugs:

- SignOut destructured `{ error }` off `.then(() => {})`, which resolves to
  undefined, so every sign-out threw a TypeError - after the signed-out event had
  already been emitted. Sign-out also left the user on the protected page they
  were on, still showing its content; it now returns them to the home page and
  re-runs the server loads.

- SignUp passed `redirectTo`, which is not a signUp option and was silently
  ignored, so the confirmation link has always used Supabase's configured site
  URL. Documented rather than changed, since pointing it elsewhere needs an
  absolute allow-listed URL.

- The Pokédex page tracked totalRecordsCreated but never passed it to the box
  view, so the "Processed N entries so far" progress message never rendered.

The rest is typing and dead code: cookie callback parameters in hooks.server.ts
and +layout.ts, the untyped supabase props, a query-builder type that made
PostgREST rows untyped downstream, an unused session destructure, and
`while (true)` paging loops rewritten as `for (;;)`.
This commit is contained in:
Josh Creek
2026-09-13 17:36:14 +01:00
parent 92d6460765
commit 3a2c18bbeb
13 changed files with 60 additions and 60 deletions
+2 -2
View File
@@ -11,8 +11,8 @@
currentPage = Math.max(currentPage - 1, 1);
}
function setItemsPerPage(event: any) {
itemsPerPage = parseInt(event.target.value, 10);
function setItemsPerPage(event: Event) {
itemsPerPage = parseInt((event.target as HTMLSelectElement).value, 10);
}
</script>
+2 -1
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import type { SupabaseClient } from '@supabase/supabase-js';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
@@ -12,7 +13,7 @@
let errorMessage = '';
// Access the supabase client from the layout data
export let supabase: any;
export let supabase: SupabaseClient;
async function signInWithEmail() {
isLoading = true;
+11 -5
View File
@@ -1,5 +1,7 @@
<script lang="ts">
import type { SupabaseClient } from '@supabase/supabase-js';
import { createEventDispatcher } from 'svelte';
import { goto } from '$app/navigation';
const dispatch = createEventDispatcher();
function emitSignedOutEvent() {
@@ -7,13 +9,17 @@
}
// Access the supabase client from the layout data
export let supabase: any;
export let supabase: SupabaseClient;
async function signOut() {
// TODO use the error from the response
const { error } = await supabase.auth.signOut().then(() => {
emitSignedOutEvent();
});
// `.then(() => {...})` resolved to undefined, so destructuring `error` off it threw a
// TypeError on every sign-out - after the event had already been emitted.
const { error } = await supabase.auth.signOut();
if (error) console.error('Sign out failed', error);
emitSignedOutEvent();
// Signing out used to leave the user sitting on the protected page they were on, still
// showing its content. Send them to the public home page and re-run the server loads.
await goto('/', { invalidateAll: true });
}
</script>
+6 -6
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import type { SupabaseClient } from '@supabase/supabase-js';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
@@ -6,17 +7,16 @@
let password = '';
// Access the supabase client from the layout data
export let supabase: any;
export let supabase: SupabaseClient;
async function signUpNewUser() {
try {
// `redirectTo` is not a signUp option - it was silently ignored, so the confirmation
// link has always used Supabase's configured site URL. Sending the user to /welcome
// would need `emailRedirectTo` with an absolute, allow-listed URL.
const { data, error } = await supabase.auth.signUp({
email: email,
password: password,
options: {
// Redirect URL after successful sign-up
redirectTo: '/welcome'
}
password: password
});
if (error) {
@@ -12,11 +12,11 @@
export let creatingRecords = false;
export let totalRecordsCreated = 0;
export let failedToLoad = false;
export let markBoxAsNotCaught = (boxNumber: number) => {};
export let markBoxAsCaught = (boxNumber: number) => {};
export let markBoxAsNeedsToEvolve = (boxNumber: number) => {};
export let markBoxAsInHome = (boxNumber: number) => {};
export let markBoxAsNotInHome = (boxNumber: number) => {};
export let markBoxAsNotCaught: (boxNumber: number) => void = () => {};
export let markBoxAsCaught: (boxNumber: number) => void = () => {};
export let markBoxAsNeedsToEvolve: (boxNumber: number) => void = () => {};
export let markBoxAsInHome: (boxNumber: number) => void = () => {};
export let markBoxAsNotInHome: (boxNumber: number) => void = () => {};
export let createCatchRecords = () => {};
export let onPokemonClick: (pokemon: CombinedData) => void = () => {};