© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
beerman

correct types for this function?

How would you correctly type
getTokenIds()
getTokenIds()
?
export const getTokens = async () => {
  return await supabase.from('tokens').select('*')
}
export const getTokenIds = tokens => {
  return tokens.data!.map(token => token.coingecko_id).filter(id => id != null)
}
export const getTokens = async () => {
  return await supabase.from('tokens').select('*')
}
export const getTokenIds = tokens => {
  return tokens.data!.map(token => token.coingecko_id).filter(id => id != null)
}


getTokens()
getTokens()
returns
{
  error: null,
  data: [{some data}, {some data}]
}
{
  error: null,
  data: [{some data}, {some data}]
}

would be used in this context
const tokens = await getTokens()
const ids = getTokenIds(tokens)
const tokens = await getTokens()
const ids = getTokenIds(tokens)
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

[Updated] How to get correct types for nested fields without losing types for main object
SupabaseSSupabase / help-and-questions
4y ago
VSCode IntelliSense not working for Supabase-generated types despite correct setup
SupabaseSSupabase / help-and-questions
4w ago
Stripe Types Not Inferred In Supabase Function
SupabaseSSupabase / help-and-questions
4y ago
Recommended pattern for Return Types on RPC functions
SupabaseSSupabase / help-and-questions
7mo ago