supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

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

Open lkp-k opened this issue 2 years ago • 5 comments

Bug report

  • [ ] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

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

  • OS: Mac OS
  • Version of supabase-js: 2.36.0
  • Version of Node.js: 18.15.0

Additional context

Add any other context about the problem here.

lkp-k avatar Sep 22 '23 22:09 lkp-k

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 avatar Oct 21 '23 20:10 lakshya-dhariwal

A quick fix I used avoid the error

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

lakshya-dhariwal avatar Oct 21 '23 20:10 lakshya-dhariwal

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

Any other solutions here?

rhh4x0r avatar Jan 04 '24 04:01 rhh4x0r

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.

piers109uk avatar Feb 02 '24 00:02 piers109uk

A quick fix I used avoid the error

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

Thank you so munch!

Erickgiber avatar Apr 06 '24 03:04 Erickgiber