TypeScript complains on `CredentialsConfig`
Discussed in https://github.com/nextauthjs/next-auth/discussions/2672
Originally posted by Rhym September 6, 2021
Good morning! I am updating my next auth in preparation for the 4.0 release and my previously working Credentials provider has an issue with the authorize callback.
I receive a
"Types of parameters 'credentials' and 'credentials' are incompatible. Type 'Record<never, string>' is missing the following properties from type '{ username: string; password: string; }': username, password". "The expected type comes from property 'authorize' which is declared here on type 'Partial<CredentialsConfig<{}>>'"
I see that the CredentialsConfig takes a generic, but I'm not actually sure where to set the config. Any help would be appreciated, thank you. Example of my code:
providers: [
// https://next-auth.js.org/configuration/providers
CredentialsProvider({
id: "login",
name: "Login",
credentials: {
username: {},
password: {},
},
authorize: async (credentials: { username: string; password: string }) => {
const DATA = { username: credentials.username, password: credentials.password };
// Login logic...
},
}),
],
The problem is in this file:
https://github.com/nextauthjs/next-auth/blob/beta/src/providers/credentials.ts
PRs welcome, otherwise I'll dig into it once I have the time.
Hi @Rhym
So the general thinking is that whatever fields you define on credentials will be available in the authorize callback, like so:

There was a small issue with the type I think, which I now corrected in #2683.
This all means that you don't actually need a generic!
Awesome, thank you @balazsorban44 for your swift response. So will that be available in BETA 2
Yes, hoping to release it soon. Currently awaiting #2655
Oh, that's a nice feature. Looking forward to the release. Have a great day!
4.0.0-beta.2 has been released, including a fix for this!
Hey, @balazsorban44 I've updated to beta.2 and now I get a fun new message with the following code:
providers: [
Credentials({
name: "Credentials",
credentials: {
username: {
label: "username",
type: "text",
},
password: {
label: "password",
type: "password",
},
},
async authorize(credentials, _req) {
// Auth logic...
},
}),
],
Typescript error:
Type 'CredentialsConfig<{ username: { label: string; type: string; }; password: { label: string; type: string; }; }>' is not assignable to type 'Provider'.
Type 'CredentialsConfig<{ username: { label: string; type: string; }; password: { label: string; type: string; }; }>' is not assignable to type 'CredentialsConfig<{}>'.
Types of property 'authorize' are incompatible.
Type '(credentials: Record<"username" | "password", string>, req: NextApiRequest) => Awaitable<Omit<User, "id"> | { id?: string | undefined; } | null>' is not assignable to type '(credentials: Record<never, string>, req: NextApiRequest) => Awaitable<Omit<User, "id"> | { id?: string | undefined; } | null>'.
Types of parameters 'credentials' and 'credentials' are incompatible.
Type 'Record<never, string>' is missing the following properties from type 'Record<"username" | "password", string>': username, password
Looks like the update to the config had a side effect?
I cannot seem to reproduce:
1.
2.

If you still have issues, please open a new issue with a reproduction. :wink:
I have the same Typescript error:
Type 'CredentialsConfig<{ username: { label: string; type: string; }; password: { label: string; type: string; }; }>' is not assignable to type 'Provider'.
Type 'CredentialsConfig<{ username: { label: string; type: string; }; password: { label: string; type: string; }; }>' is not assignable to type 'CredentialsConfig<{}>'.
Types of property 'authorize' are incompatible.
Type '(credentials: Record<"username" | "password", string>, req: NextApiRequest) => Awaitable<Omit<User, "id"> | { id?: string | undefined; } | null>' is not assignable to type '(credentials: Record<never, string>, req: NextApiRequest) => Awaitable<Omit<User, "id"> | { id?: string | undefined; } | null>'.
Types of parameters 'credentials' and 'credentials' are incompatible.
Type 'Record<never, string>' is missing the following properties from type 'Record<"username" | "password", string>': username, password
then please provide a reproduction. 😊 as mentioned, I cannot reproduce it
Yes! I made this issue with a reproduction #2701