export function getSettings<T, S extends (Subset<T> & Record<string, any>)[]>(
		target: T, ...sources: S
): MergedSettings<T, S>


This function merges partial objects into a target. If no sources are specified, a duplicate of the target will be returned. The sources are handled in the order they are provided, with any properties in later sources superseding those in earlier ones. If a source property is an object, it will be merged with the corresponding target property.

This function is widely used throughout the framework to add to existing settings, create new layers of settings, or customise variants.


This function can be imported as such:

import {getSettings} from '@unless/component-library.utils.helpers'


targetTThe destination to merge into. Any properties that are redefined in the sources will take precedence over those in the destination, and any new properties will be added. Note: If a sub-property is only partially redefined in the sources, only that part will be overridden.
...sources(Subset<T> & Record<string, any>)[]This refers to any object. Properties that match the structure of target should be of the same data type. The priority of sources is in the descending order into which they are provided.


  • MergedSettings<T, S>
    • The getSettings function returns an object of type MergedSettings<T, S>, where T is the target object type and S is the union of all the sources. The MergedSettings type is a helper type that represents the merged object of the T and S types, with the properties of S taking precedence over the corresponding properties of T.
    • The MergedSettings type is used to ensure that the returned object is a complete and correct representation of the merged object, with all properties accounted for and properly typed.

What’s Next