supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
2.86k stars 220 forks source link

Compilation errors - is this package actually isomorphic or am I using the wrong package? #860

Open lkp-k opened 7 months ago

lkp-k commented 7 months ago

Bug report

Describe the bug

There is some issue with @types/phoenix and since I'm using typescript I get compilation error.

I realize that CloseEvent exists on browser, and I want to use supabase-js purely on backend. I'm wondering - am I using the wrong package for this? Something like "admin-sdk".

And there are a bunch of other issues too:


node_modules/@supabase/functions-js/dist/module/types.d.ts(1,36): error TS2304: Cannot find name 'fetch'.
node_modules/@supabase/functions-js/dist/module/types.d.ts(42,12): error TS2304: Cannot find name 'File'.
node_modules/@supabase/functions-js/dist/module/types.d.ts(42,40): error TS2304: Cannot find name 'FormData'.
node_modules/@supabase/functions-js/dist/module/types.d.ts(42,51): error TS2304: Cannot find name 'ReadableStream'.
node_modules/@supabase/gotrue-js/dist/module/GoTrueClient.d.ts(52,33): error TS2749: 'BroadcastChannel' refers to a value, but is being used as a type here. Did you mean 'typeof BroadcastChannel'?
node_modules/@supabase/gotrue-js/dist/module/lib/fetch.d.ts(2,36): error TS2304: Cannot find name 'fetch'.
node_modules/@supabase/gotrue-js/dist/module/lib/fetch.d.ts(30,60): error TS2304: Cannot find name 'Response'.
node_modules/@supabase/gotrue-js/dist/module/lib/helpers.d.ts(15,29): error TS2304: Cannot find name 'fetch'.
node_modules/@supabase/gotrue-js/dist/module/lib/helpers.d.ts(17,91): error TS2304: Cannot find name 'Response'.
node_modules/@supabase/gotrue-js/dist/module/lib/types.d.ts(868,62): error TS2304: Cannot find name 'Storage'.
node_modules/@supabase/postgrest-js/dist/module/types.d.ts(1,36): error TS2304: Cannot find name 'fetch'.
node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts(7,17): error TS2304: Cannot find name 'WebSocket'.
node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts(51,11): error TS2304: Cannot find name 'WebSocket'.
node_modules/@supabase/realtime-js/dist/module/RealtimePresence.d.ts(1,15): error TS2305: Module '"phoenix"' has no exported member 'PresenceOpts'.
node_modules/@supabase/realtime-js/dist/module/RealtimePresence.d.ts(1,29): error TS2305: Module '"phoenix"' has no exported member 'PresenceOnJoinCallback'.
node_modules/@supabase/realtime-js/dist/module/RealtimePresence.d.ts(1,53): error TS2305: Module '"phoenix"' has no exported member 'PresenceOnLeaveCallback'.
node_modules/@supabase/storage-js/dist/module/lib/fetch.d.ts(2,36): error TS2304: Cannot find name 'fetch'.
node_modules/@supabase/storage-js/dist/module/packages/StorageFileApi.d.ts(5,73): error TS2304: Cannot find name 'File'.
node_modules/@supabase/storage-js/dist/module/packages/StorageFileApi.d.ts(5,80): error TS2304: Cannot find name 'FormData'.
node_modules/@supabase/storage-js/dist/module/packages/StorageFileApi.d.ts(5,115): error TS2304: Cannot find name 'ReadableStream'.
node_modules/@supabase/storage-js/dist/module/packages/StorageFileApi.d.ts(77,84): error TS2304: Cannot find name 'File'.
node_modules/@supabase/storage-js/dist/module/packages/StorageFileApi.d.ts(77,91): error TS2304: Cannot find name 'FormData'.
node_modules/@supabase/storage-js/dist/module/packages/StorageFileApi.d.ts(77,126): error TS2304: Cannot find name 'ReadableStream'.
node_modules/@supabase/supabase-js/dist/module/lib/types.d.ts(6,36): error TS2304: Cannot find name 'fetch'.
node_modules/@types/phoenix/index.d.ts(81,29): error TS2304: Cannot find name 'CloseEvent'.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Install latest supabase-js while using typescript and try running it.

Expected behavior

No compilation error.

Screenshots

System information

Additional context

Add any other context about the problem here.

lakshya-dhariwal commented 6 months ago

I was following some blog using this library in a nodejs project without TS. I tried the same in my TS nodejs project and getting similar issue as this.

Screenshot 2023-10-22 at 1 31 59 AM Screenshot 2023-10-22 at 1 32 20 AM

lakshya-dhariwal commented 6 months ago

A quick fix I used avoid the error

//tsconfig
{
  "compilerOptions": {
    "skipLibCheck": true
  },
}
rhh4x0r commented 4 months ago

Same issue here. I can compile with skipLibCheck as true.

Any other solutions here?

piers109uk commented 3 months ago

Rather than "skipLibCheck" I added "lib": ["ESNext", "DOM"] to my tsconfig.json and that also fixed it (DOM is the important part). I need to decide which solution I like least: Accepting DOM types in my server-only package, or skipping lib checking entirely. Would love a third option if anyone finds one.

Erickgiber commented 1 month ago

A quick fix I used avoid the error

//tsconfig
{
  "compilerOptions": {
    "skipLibCheck": true
  },
}

Thank you so munch!