I have a function/hook which returns an array with types boolean and MyErrorType
export declare const getErrorData: () => readonly [ boolean, MyErrorType ];
In some scenarios I am only interested in the 2nd value of the array of type MyErrorType and I was wondering if there is a clean way to get this? Currently only solution I could get to work is just fetching the 2nd element in the array i.e.
const error = getErrorData()[1];
Is there any way to fetch the element of the array based on the type of the variable? something like
const error: MyErrorType = getErrorData();