• We want to provide methods which accept a variable single number of elements and arrays. The overloaded signature to achieve this is:

    function doSomething(array: T[])
    function doSomething(...varArgs: T[])
    function doSomething(first: undefined | T | T[], ...rest: T[]) {
    //implementation
    }

    This wrapper methods makes it easy build an array from the input.

    Returns

    Array from the input or empty array if no input was given.

    Deprecated

    This method should be replaced by transformVariadicArgumentToArray.

    Type Parameters

    • T

    Parameters

    • firstOrArray: undefined | T | T[]

      Either an array, the first element of the var args or undefined, if no argument was given.

    • rest: T[]

      Second to last element, if var args were used, empty array, if the first argument is an array.

    Returns T[]

Copyright Ⓒ 2023 SAP SE or an SAP affiliate company. All rights reserved.