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) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1766780bca
commit
b1edb5c460
@@ -85,11 +85,11 @@ export default function CommsClient({ member, space, channels }: Props) {
|
||||
m.id.startsWith('temp-') &&
|
||||
m.user_id === payload.new.user_id &&
|
||||
m.content === payload.new.content
|
||||
? payload.new
|
||||
? (payload.new as Message)
|
||||
: m,
|
||||
)
|
||||
}
|
||||
return [...prev, payload.new]
|
||||
return [...prev, payload.new as Message]
|
||||
})
|
||||
},
|
||||
)
|
||||
@@ -105,6 +105,7 @@ export default function CommsClient({ member, space, channels }: Props) {
|
||||
}, [messages])
|
||||
|
||||
async function loadMessages() {
|
||||
if (!selectedChannel) return
|
||||
const supabase = createClient()
|
||||
const { data } = await supabase
|
||||
.from('comms_messages')
|
||||
@@ -119,6 +120,7 @@ export default function CommsClient({ member, space, channels }: Props) {
|
||||
e.preventDefault()
|
||||
const content = newMessage.trim()
|
||||
if (!content || sending) return
|
||||
if (!selectedChannel) return
|
||||
setSending(true)
|
||||
|
||||
// Optimistic insert — message appears immediately for the sender
|
||||
@@ -133,7 +135,7 @@ export default function CommsClient({ member, space, channels }: Props) {
|
||||
content,
|
||||
created_at: new Date().toISOString(),
|
||||
}
|
||||
setMessages(prev => [...prev, optimisticMsg])
|
||||
setMessages(prev => [...prev, optimisticMsg as Message])
|
||||
setNewMessage('')
|
||||
|
||||
const supabase = createClient()
|
||||
@@ -142,7 +144,7 @@ export default function CommsClient({ member, space, channels }: Props) {
|
||||
.insert({
|
||||
channel_id: selectedChannel.id,
|
||||
space_id: space?.id ?? member.space_id,
|
||||
user_id: member.user_id,
|
||||
user_id: member.user_id as string,
|
||||
display_name: member.display_name,
|
||||
handle: member.handle,
|
||||
content,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createClient } from '@/lib/supabase/server'
|
||||
import type { Tables } from '@/types/database'
|
||||
import CommsClient from './comms-client'
|
||||
|
||||
export default async function CommsPage() {
|
||||
@@ -17,5 +18,5 @@ export default async function CommsPage() {
|
||||
.order('channel_type')
|
||||
.order('name')
|
||||
|
||||
return <CommsClient member={member} space={member?.spaces} channels={channels ?? []} />
|
||||
return <CommsClient member={member} space={member?.spaces as Tables<'spaces'>} channels={channels ?? []} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user