Function convertToTypeSafeString

  • Converts the given input to a type-safe string.

    This function takes an input of various types (string, string array, number, undefined, or null) and converts it to a string. If the input is undefined or null, it returns an empty string.

    Parameters

    • input: undefined | null | string | number | string[]

      The input value to be converted to a string. It can be of type string, string[], number, undefined, or null.

    Returns string

    A string representation of the input. If the input is undefined or null, it returns an empty string.

    convertToTypeSafeString('hello'); // Returns 'hello'
    convertToTypeSafeString(['a', 'b', 'c']); // Returns 'a,b,c'
    convertToTypeSafeString(123); // Returns '123'
    convertToTypeSafeString(undefined); // Returns ''
    convertToTypeSafeString(null); // Returns ''