types: clear remaining tsc errors across 41 files (76→14, behavior-preserving)

Per-file type-only fixes surfaced after the Supabase client was correctly
typed. All fixes preserve runtime behavior; no any/ts-ignore/ts-expect-error.

- lib/supabase/client.ts: annotate the browser client as SupabaseClient<Database>
  (same ssr/js drift as server.ts; fixes it centrally for all callers).
- Supabase embedded-select joins whose FK metadata is missing from the
  generated types are bridged with `as unknown as <target>` + a TODO to remove
  after regenerating types/database.ts.
- setState optimistic-update variance and raw <select> enum values cast to the
  precise element/union type; .insert payload fields (Json, enums) given the
  precise column type via satisfies/field casts.
- Added narrowing guards where a value was legitimately nullable (comms channel,
  public form page) without changing the intended path.

The 14 remaining errors are confined to the four files fixed in Phase B (real
bugs + the tautological actions.test rewrite). 639 tests still green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Moheeb Zara
2026-08-01 18:56:11 -07:00
co-authored by Claude Opus 4.8
parent 1766780bca
commit b1edb5c460
41 changed files with 148 additions and 59 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import { sendEmail } from '@/lib/email/send'
const OLD = { ...process.env }
function mockFetch(status: number, body: unknown) {
return vi.fn(async () =>
return vi.fn(async (_input?: Request | string | URL, _init?: RequestInit) =>
new Response(JSON.stringify(body), {
status,
headers: { 'content-type': 'application/json' },
+2 -1
View File
@@ -1,4 +1,5 @@
import { describe, it, expect } from 'vitest'
import type { ReactNode } from 'react'
import {
headingText,
slugifyHeading,
@@ -13,7 +14,7 @@ describe('headingText', () => {
})
it('flattens arrays and element children', () => {
expect(headingText(['Get ', 'started'])).toBe('Get started')
expect(headingText({ props: { children: ['Bold ', { props: { children: 'bit' } }] } })).toBe('Bold bit')
expect(headingText({ props: { children: ['Bold ', { props: { children: 'bit' } }] } } as ReactNode)).toBe('Bold bit')
})
it('ignores null/boolean', () => {
expect(headingText(null)).toBe('')
+1 -1
View File
@@ -90,7 +90,7 @@ describe('enqueueNotification', () => {
const admin = mockAdmin({ upsertResult: { error: null } })
await enqueueNotification(admin as never, params)
expect(admin.from).toHaveBeenCalledWith('notifications')
const [row, opts] = admin.upsert.mock.calls[0] as [Row, Row]
const [row, opts] = admin.upsert.mock.calls[0] as unknown as [Row, Row]
expect(row).toMatchObject({
space_id: 'space-1',
member_id: 'member-1',
+1 -1
View File
@@ -74,7 +74,7 @@ describe('String Utilities', () => {
})
it('should handle empty name', () => {
const name = ''
const name: string = ''
const initials = name ? name.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2) : '??'
expect(initials).toBe('??')
})