I am working with a function/hook that returns an array containing values of type boolean
and MyErrorType
export declare const getErrorData: () => readonly [ boolean, MyErrorType ];
There are instances where I only need the 2nd value in the array, which is of type MyErrorType
. I'm looking for a cleaner way to retrieve this specific value. Currently, the only solution I have found is accessing the 2nd element directly from the array like this:
const error = getErrorData()[1];
Is there a method to extract the array element based on the variable type? For example:
const error: MyErrorType = getErrorData();