Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Object-like type definition: can someone explain?

I’m working with a library that uses the following type definition:

export interface Auth0ContextInterface<TUser extends User = User> extends AuthState<TUser> {
  getAccessTokenSilently: {
    (options: GetTokenSilentlyOptions & { detailedResponse: true }): Promise<
      GetTokenSilentlyVerboseResponse
    >;
    (options?: GetTokenSilentlyOptions): Promise<string>;
    (options: GetTokenSilentlyOptions): Promise<
      GetTokenSilentlyVerboseResponse | string
    >;
  };
  
  ...

Can someone explain what the getAccessTokenSilently definition means? I assumed that it was another way of joining multiple types, but none of these work in the codebase I’m working on.

Help would be much appreciated!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It a function overload type definition,

The getAccessTokenSilently method on oyur object has 3 different definitions :

  • (options: GetTokenSilentlyOptions & { detailedResponse: true }): Promise< GetTokenSilentlyVerboseResponse>
  • (options?: GetTokenSilentlyOptions): Promise<string>;
  • (options: GetTokenSilentlyOptions): Promise< GetTokenSilentlyVerboseResponse | string>;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading