1

How can I (properly) use the locally downloaded types of my supabase db for use in an Edge Functions environment (Deno) to provide autocomplete suggestions in VS Code?

I tried doing it similarly to how it was done in my react supabase:

import "jsr:@supabase/functions-js/edge-runtime.d.ts"
import { createClient, SupabaseClient } from 'jsr:@supabase/supabase-js@2'
import { Database } from "../_types/supabase.ts";

const supabase = createClient<Database>(
      Deno.env.get('SUPABASE_URL') ?? '',
      Deno.env.get('SUPABASE_ANON_KEY') ?? '',
      { global: { headers: { Authorization: req.headers.get('Authorization')! } } }
    )

But it doesn't seem to be working as VS Code isn't suggesting an autocomplete of my tables if I type it.

3
  • Can you edit the question to clarify the problem — and include a minimal reproducible example? The content of all relevant files should be included directly in the question, and I don’t see any information about where you expect IntelliSense suggestions and aren’t getting any from the language server. Commented Sep 12, 2024 at 20:35
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Sep 15, 2024 at 13:57
  • @jsejcksn createClient<Database>, adding the Database types is supposed to make the resulting supabase value have intellisense and types awareness. Instead, it's still any Commented Nov 3, 2024 at 2:51

1 Answer 1

2

Ok after lots of work, and trying everything from this github discussion, the thing that immediately worked for me was opening my supabase-functions workspace directly, in a new vs-code window.

Definitely need the vscode deno extension.

So the folder that contains .vscode/settings.json and my supabase/functions folders. Is a specific project/workspace. The intellisense doesn't scope to that directories settings - if it is contained inside a larger project, and you open that project's higher parent folder, then drill down into these supabase functions.

You have to specifically open vscode to the folder with your supabase/ directory. Worked on my machine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.