I am facing an issue with my async function that is supposed to return either a single string or an array of strings. Here is the relevant code snippet:
async getAllAnnotationTimes(): Promise<string> | Promise<string[]> {
return await this.app.client.getText(this.allAnnotationPositions);
}
In addition, I have also tried using the following declaration:
Promise<string> | Promise<Array<string>>
However, it resulted in this error message:
[ts] The return type of an async function or method must be the global Promise<T> type.
The error seems to be related to the section after the or
, particularly with
Promise<Array<string>>
Could someone please advise on how to correctly declare a promise for a string array?