Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

332
Views
Eslint error with Array forEach iteration: Promise returned in function argument where a void return was expected

I'm trying to write a function to do transformation for Files which are not throwing any exception like a method below. I'm seeing ESLint error - "Eslint: Promise returned in function argument where a void return was expected.". What can be done to fix this eslint?

Note we would skip the files which will throw Error. Those are appropriately logged though.

export async function createDataFromFiles(inputFiles: File[]): Promise<Data[]> {
        const result: Data = [];
    
        inputFiles.forEach(
            async (file) => {
                const imageData = new DataView(await file.arrayBuffer());
                const blobUrl = URL.createObjectURL(new Blob([imageData]));
                try {
                    const dimension = await getDimensionsFromImageUrl(blobUrl);
                    answer.push({ imageData, dimension });
                } finally {
                    URL.revokeObjectURL(blobUrl);
                }
            }
        );
    
        return Promise.all(answer);
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is because of the signature of Array.forEach:

forEach(callbackfn: (value: undefined, index: number, array: undefined[]) => void): void.

The callbackFn has type void, but when using async the function implicitly returns a Promise.

You can avoid this warning by using an ordinary for...of loop:

export async function createDataFromFiles(inputFiles: File[]): Promise<Data[]> {
    const result: Data = [];

    for (const file of inputFiles) {
        const imageData = new DataView(await file.arrayBuffer());
        const blobUrl = URL.createObjectURL(new Blob([imageData]));
        try {
            const dimension = await getDimensionsFromImageUrl(blobUrl);
            answer.push({ imageData, dimension });
        } finally {
            URL.revokeObjectURL(blobUrl);
        }
    }

    return Promise.all(answer);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!