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

useSupabaseClient, useSupabaseSession, useSupabaseUser all resolve types to any #383

Closed
Pimeq opened this issue Jul 6, 2024 · 19 comments
Closed
Labels
question Further information is requested

Comments

@Pimeq
Copy link

Pimeq commented Jul 6, 2024

I've tried with npm and bun to install and use nuxt-supabase, however from version 1.3.1, all the composable resolve their return type to any, I've tried set up a clean VSCode profile with just Typescript nightly and vue-official tools installed, still no luck and type resolution is still to any. Screens are from the clean profile on VSCode:
image
image
image

@Pimeq Pimeq added the question Further information is requested label Jul 6, 2024
@Pimeq
Copy link
Author

Pimeq commented Jul 6, 2024

I forgot to add versions in the project so here:
image

@JJosephttg
Copy link

Same issue here. Downgrading to 1.2.0 gives the type for client, however useSupabaseUser was still any. The typing files are just empty

@ifzm
Copy link

ifzm commented Jul 7, 2024

Me too, normal after returning to 1.2

@XStarlink
Copy link

It may comes from this PR who was merged in v1.3.1: #366

@larbish
Copy link
Collaborator

larbish commented Jul 9, 2024

@IsraelOrtuno could you have a check at this? Seems to be related to your PR.

@IsraelOrtuno
Copy link
Contributor

@IsraelOrtuno could you have a check at this? Seems to be related to your PR.

Let me to it...

@IsraelOrtuno
Copy link
Contributor

All seems good when running it within the playground folder but I agree that it's not working as expected when installing the package as a dependence.

The file node_modules/@nuxtjs/supabase/dist/runtime/composables/useSupabaseSession.d.ts is empty (as many others *.d.ts) and this does not happen in previous versions. I see declaration was set to false in .tsconfig.

56dc39e#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0R5

https://www.typescriptlang.org/tsconfig/#declaration

Generate .d.ts files for every TypeScript or JavaScript file inside your project. These .d.ts files are type definition files which describe the external API of your module. With .d.ts files, tools like TypeScript can provide intellisense and accurate types for un-typed code.

Seems to be the cause to me. @larbish do you think this can be related?

If so, not sure if this could be fixed by omitting that property or if there's a way to force generating certain .d.ts files.

@GrantlyNeely
Copy link

I found the same thing. All my .d.ts files were empty when I switched to 1.3, switched back to 1.2 and the .d.ts were successfully generated.

@onurusluca
Copy link
Contributor

Same here

@XStarlink
Copy link

Me too, the ./nuxt/types/supabase-database.d.ts file contains:

export type Database = unknown

However, I named my type file as the doc says: ./types/database.types.ts

@IsraelOrtuno
Copy link
Contributor

IsraelOrtuno commented Jul 11, 2024

The proxy typing works fine on my end when the file exists, the problem seems to be more related to:

#383 (comment)

declaration was set to false on the .tsconfig file which is likely to be preventing the generation of the .d.ts to know what's returned by the package composables, nothing to do with the database typings. @larbish could have done this for a reason as seems to be included in a large migration PR, let's wait until he can let us know why and if there aren't other side effects.

@onurusluca
Copy link
Contributor

Probably related:

/api/supabase/cart:
image

import { serverSupabaseClient } from "#supabase/server";

File 'c:/CODING STUFF/PROJECTS/ucus-marketi/frontend/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxtjs/supabase/dist/runtime/server/services/index.d.ts' is not a module.ts(2306)

"nuxt": "3.12.2",
"@nuxtjs/supabase": "^1.3.4",

@larbish
Copy link
Collaborator

larbish commented Jul 15, 2024

Should be resolved in 1.3.5

@larbish larbish closed this as completed Jul 15, 2024
@XStarlink
Copy link

XStarlink commented Jul 17, 2024

Hello @IsraelOrtuno, I'm in v1.3.5 with a fresh "npx nuxi upgrade -f" install,
I have generated the types and they exist in ./types/database.types.ts but yet when I hover over data or supabase client I don't get the types if I don't pass it when I use the client, is this normal?

@IsraelOrtuno
Copy link
Contributor

Hello @IsraelOrtuno, I'm in v1.3.5 with a fresh "npx nuxi upgrade -f" install, I have generated the types and they exist in ./types/database.types.ts but yet when I hover over data or supabase client I don't get the types if I don't pass it when I use the client, is this normal?

The problem is there but it's not related to this thread, 1.3.5 fixed the issue of composables returning any, that's not anymore.

I will open an issue myself to track this. Seems like types are lost when running the build command. When running nuxt-module-build --stub seems to work nicely so I am investigating what's causing this.

image image

@XStarlink
Copy link

@IsraelOrtuno Thank you very much!
In my case I'd just like to have the Types when I'm developing so when I'm doing a npm run dev, so I don't know what's related to the build, but thanks in any case.

@IsraelOrtuno
Copy link
Contributor

I would create a wrapper composable in the meanwhile so you don't have to pass the types manually every time you want to use the client.

@XStarlink
Copy link

I would create a wrapper composable in the meanwhile so you don't have to pass the types manually every time you want to use the client.

Hello @IsraelOrtuno isn't that what the PR #366 was supposed to allow?

Were you able to find out what the problem was?

@IsraelOrtuno
Copy link
Contributor

I would create a wrapper composable in the meanwhile so you don't have to pass the types manually every time you want to use the client.

Hello @IsraelOrtuno isn't that what the PR #366 was supposed to allow?

Were you able to find out what the problem was?

All should be fixed in 1.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants