How Does this TypeScript Constructor Work? A Default Object?

Viewed 102

How does the last argument of this constructor work?

    constructor(clientId: string, authority: string, tokenReceivedCallback: tokenReceivedCallback,
        {
            validateAuthority = true,
            cacheLocation = 'sessionStorage',
            redirectUri = window.location.href.split("?")[0].split("#")[0],
            postLogoutRedirectUri = redirectUri,
            navigateToLoginRequestUrl = true
        }:
            {
                validateAuthority?: boolean,
                cacheLocation?: string,
                redirectUri?: string,
                postLogoutRedirectUri?: string,
                navigateToLoginRequestUrl?: boolean,
            } = {}) {

        ...

    }

It would seem to me, it takes in an object and the object has been defaulted if nothing is provided, correct?

If I want to override one of the values, say, cacheLocation, how do I do that? Can I pass { cacheLocation: 'localStorage' } or do I have to define all properties in that case?


Source: MSAL.js

1 Answers
Related