Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors with TypeScript #96

Closed
ohnv opened this issue Dec 9, 2020 · 7 comments
Closed

Compilation errors with TypeScript #96

ohnv opened this issue Dec 9, 2020 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@ohnv
Copy link

ohnv commented Dec 9, 2020

Improve documentation

Link

https://supabase.io/docs/client/installing

Describe the problem

Hi, I wasn't sure whether to file this as a bug report or a documentation issue as I am not sure which it is.

Typescript and Node really aren't my forte so sorry if this is something basic, but after running the install steps at the above link and then following the createClient example (https://supabase.io/docs/client/initializing) I run into the following compilation errors while compiling with Typescript:

node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.d.ts:19:29 - error TS2304: Cannot find name 'Storage'.
19 protected localStorage: Storage;

node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.d.ts:38:24 - error TS2304: Cannot find name 'Storage'.
38 localStorage?: Storage;

node_modules/@supabase/postgrest-js/dist/main/lib/types.d.ts:33:20 - error TS2304: Cannot find name 'URL'.
33 protected url: URL;

node_modules/@supabase/supabase-js/dist/main/lib/SupabaseAuthClient.d.ts:11:24 - error TS2304: Cannot find name 'Storage'.
11 localStorage?: Storage;

node_modules/@supabase/supabase-js/dist/main/lib/types.d.ts:27:20 - error TS2304: Cannot find name 'Storage'.
27 localStorage?: Storage;

Describe the improvement

If there are additional steps required to work with Typescript, it would be nice if the documentation provided direction. Or if it already exists, maybe just a link on the installation page to the Typescript-specific documentation.

Thanks :-)

@ohnv ohnv added the documentation Improvements or additions to documentation label Dec 9, 2020
@kiwicopple
Copy link
Member

Hi @TheTrainor - this looks like it was due to some missing exports on our side.

@calendee fixed it here: #97. Can you try to instlall the latest supabase version?

npm install @supabase/supabase@latest

this should bump it to v1.1.0

@calendee
Copy link
Contributor

Unfortunately, I can't reproduce the problem even when I checkout the previous releases and build them. Hopefully I'm just doing something wrong though.

@TheTrainor Did updating the @supabase/supabase package solve the problem? 🤞

If not, can you create a public repo that demonstrates the problem?

Thanks!

@ohnv
Copy link
Author

ohnv commented Dec 10, 2020

Thanks for the help guys.

It turned out the problem was my tsconfig.json file:

"compilerOptions": {
      "experimentalDecorators": true,
      "target": "ES2015",
      "module": "commonjs",
      "outDir": "../build", 
      "noEmit": false,
      "sourceMap": true,
      "lib": [ //---
        "ES6"  // Removing these 3 lines fixed the problem.
      ]        //---
    },

Thanks for the quick response @kiwicopple and @calendee. I am looking forward to trying out Supabase properly.

@ohnv ohnv closed this as completed Dec 10, 2020
@ChronSyn
Copy link

ChronSyn commented Apr 2, 2021

Sorry for reopening this issue, but for anyone else having issues with this, ensure you have the following in your tsconfig.json

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

It seems like there might still be some weirdness going on with the lib, but it's easy enough to fix with the above.

@inian
Copy link
Member

inian commented May 13, 2021

I think we should fix the type errors here.

@inian inian reopened this May 13, 2021
@inian
Copy link
Member

inian commented May 17, 2021

Not sure if we can fix this issue in the library itself. I fixed this by adding the "DOM" to tsconfig lib attribute in the project consuming supabase-js.
The AWS SDK seems to have the same issue and they recommend adding dom types to your tsconfig file.

@soedirgo
Copy link
Member

Doesn't seem like there's a better alternative to adding DOM to lib, so closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

6 participants