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

Google provider Types are broken in v4 #2681

Closed
crubier opened this issue Sep 6, 2021 · 2 comments
Closed

Google provider Types are broken in v4 #2681

crubier opened this issue Sep 6, 2021 · 2 comments
Labels
bug Something isn't working TypeScript Issues relating to TypeScript

Comments

@crubier
Copy link

crubier commented Sep 6, 2021

Description 🐜

In v4, if I use GoogleProvider, I have to cast it to OAuthConfig<Profile> , otherwise I get the following typing error:

Type 'OAuthConfig<GoogleProfile>' is not assignable to type 'Provider'.
  Type 'OAuthConfig<GoogleProfile>' is not assignable to type 'OAuthConfig<Profile>'.
    Property 'picture' is missing in type 'Profile' but required in type 'GoogleProfile'.ts(2322)
    
    
google.d.ts(5, 5): 'picture' is declared here.

(alias) GoogleProvider<GoogleProfile>(options: OAuthUserConfig<Profile>): OAuthConfig<GoogleProfile>
import GoogleProvider

See this commit which works around the problem on our repo
labelflow/labelflow@f794e5e

Is this a bug in your own project?

No

How to reproduce ☕️

Use v4 beta 1

Use GoogleProvider with typescript.

Example: Use this commit labelflow/labelflow@f794e5e

Screenshots / Logs 📽

Screenshot 2021-09-06 at 21 13 44

Environment 🖥

 System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 77.31 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node
    Yarn: 3.0.1 - ~/.yarn/bin/yarn
    npm: 7.20.0 - ~/.nvm/versions/node/v14.15.4/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 93.1.29.77
    Chrome: 93.0.4577.63
    Edge: 93.0.961.38
    Firefox: 91.0.2
    Safari: 14.1.2
  npmPackages:
    react: 17.0.2 => 17.0.2 
    typescript: 4.3.5 => 4.3.5 

Contributing 🙌🏽

Yes, I am willing to help solve this bug in a PR

@crubier crubier added the bug Something isn't working label Sep 6, 2021
@balazsorban44
Copy link
Member

Right! I forgot about that. I haven't quite finished it at the time. But here is a fix: #2682

Basically the profile callbacks first argument will be different for any providers, depending on the scopes set by the user, so we want to keep it overrideable.

@balazsorban44 balazsorban44 added the TypeScript Issues relating to TypeScript label Sep 6, 2021
@balazsorban44 balazsorban44 reopened this Sep 7, 2021
@balazsorban44
Copy link
Member

4.0.0-beta.2 has been released, including a fix for this!

If you are using the profile callback, you will be able to override the default type like this:

FacebookProvider({
  ...
  profile(profile: YourCustomProfileType) {
    return {
      name: "",
      email: "",
      picture: "",
      id: ""
    }
  }
})

This is probably only needed if you are adding scopes other than the default.

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

No branches or pull requests

2 participants