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

Argument of type 'string' is not assignable to parameter of type 'never'. when running project that uses Supabase #181

Open
2 tasks done
eRuaro opened this issue Sep 28, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@eRuaro
Copy link

eRuaro commented Sep 28, 2023

Bug report

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

Describe the bug

A typescript type issue on the code.

To Reproduce

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

  1. Run a supabase project using storage-js

Expected behavior

Application runs with no problems!

Screenshots

If applicable, add screenshots to help explain your problem.
image

System information

  • OS: Linux
  • Version of supabase-js: 2.36.0
  • Version of storage-js: 2.5.4
  • Version of Node.js: 19.6

Additional context

Add any other context about the problem here.

I'm also getting this error when running npm run build thus I can't deploy a new version of my frontend which I was hoping to accomplish yesterday until I had this issue after I restarted my TS server.

@eRuaro eRuaro added the bug Something isn't working label Sep 28, 2023
@eRuaro
Copy link
Author

eRuaro commented Sep 28, 2023

What I found to work on my localhost is to edit the files directly from the node modules, the following functions are the ones I edited:
StorageFileApi.ts

export default class StorageFileApi {

  ...
  ...
  getPublicUrl(
    path: string,
    options?: { download?: string | boolean; transform?: TransformOptions }
  ): { data: { publicUrl: string } } {
    const _path = this._getFinalPath(path)
    // specify list type
    const _queryString: string[] = []

    const downloadQueryParam = options?.download
      ? `download=${options.download === true ? '' : options.download}`
      : ''

    if (downloadQueryParam !== '') {
      _queryString.push(downloadQueryParam)
    }

    const wantsTransformation = typeof options?.transform !== 'undefined'
    const renderPath = wantsTransformation ? 'render/image' : 'object'
    const transformationQuery = this.transformOptsToQueryString(options?.transform || {})

    if (transformationQuery !== '') {
      _queryString.push(transformationQuery)
    }

    let queryString = _queryString.join('&')
    if (queryString !== '') {
      queryString = `?${queryString}`
    }

    return {
      data: { publicUrl: encodeURI(`${this.url}/${renderPath}/public/${_path}${queryString}`) },
    }
  }

  ...
  ...
  private transformOptsToQueryString(transform: TransformOptions) {
    // specify the type of the array
    const params: string[] = []
    if (transform.width) {
      params.push(`width=${transform.width}`)
    }

    if (transform.height) {
      params.push(`height=${transform.height}`)
    }

    if (transform.resize) {
      params.push(`resize=${transform.resize}`)
    }

    if (transform.format) {
      params.push(`format=${transform.format}`)
    }

    if (transform.quality) {
      params.push(`quality=${transform.quality}`)
    }

    return params.join('&')
  }

}

@eRuaro
Copy link
Author

eRuaro commented Sep 28, 2023

Also, editing my project's tsconfig.json by removing "strict": true works but doesn't that defeat the case of using typescript?

@bkan36
Copy link

bkan36 commented May 22, 2024

I had this kind of issue when using supabase.from.update(object)

object is a generic type "T"

issue: "Argument of type 'T' is not assignable to parameter of type 'never'"

and fix it simply by declaring my supabase variable
like this

supabase: any = useSupabaseClient()

@FalianaRanai
Copy link

I had this kind of issue when using supabase.from.update(object)

object is a generic type "T"

issue: "Argument of type 'T' is not assignable to parameter of type 'never'"

and fix it simply by declaring my supabase variable like this

supabase: any = useSupabaseClient()

worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants