I'm puzzled as to why the return type string
in this method is showing up as a red error:
exportPageAsText(pageNumber: number): string {
(async () => {
const text = await this.pdfViewerService.getPageAsText(pageNumber);
console.log(text);
return text;
})();
}
The error message states:
A function whose declared type is neither 'void' nor 'any' must return a value.
so I tried moving return text;
outside of the async
block and placing it after })();
, but then the text
variable became unrecognized.
At that point, I considered changing the method's signature to use a Promise
like so:
exportPageAsText(pageNumber: number): Promise<string>
However, I encountered another error stating that
A function whose declared type is neither 'void' nor 'any' must return a value.
If anyone could shed some light on what I might be doing incorrectly, I would greatly appreciate it.