0

I bumped to this definition when I was browsing Next-auth.js type definition.

export declare function signIn<P extends RedirectableProviderType | undefined = undefined>(provider?: LiteralUnion<BuiltInProviderType>, options?: SignInOptions, authorizationParams?: SignInAuthorizationParams): Promise<P extends RedirectableProviderType ? SignInResponse | undefined : undefined>;

What does undefined = undefined part of the definition mean?

ANTARES_SEO
  • 317
  • 4
  • 9
  • 2
    you should read it like `P extends RedirectableProviderType | undefined` , the default value is `undefined` – coglialoro Apr 21 '22 at 09:53

1 Answers1

2

P extends RedirectableProviderType | undefined = undefined means that RedirectableProviderType or undefined types are allowed to be asserted when invoking signIn (e.g. signIn<RedirectableProviderType>), however when no assertion type is provided - P will be defaulted to undefined.

This can alternatively be viewed as P (extends RedirectableProviderType | undefined) = undefined

Ovidijus Parsiunas
  • 2,512
  • 2
  • 8
  • 18