fixing types

This commit is contained in:
2025-07-23 13:40:14 +02:00
parent 46730aa249
commit 491b11e86d
2 changed files with 6 additions and 5 deletions

View File

@@ -330,7 +330,7 @@ const copyBarcodeImage = (canvas:HTMLCanvasElement, decoderResult:Result):string
}
/** Finds PDF417 code within a file and decodes it */
const decodeFromFile = async (file:File) => {
const decodeFromFile = async (file:File): Promise<DecodeResult[]|null> => {
switch(file.type) {
case 'image/png':
case 'image/jpeg':
@@ -341,13 +341,13 @@ const decodeFromFile = async (file:File) => {
// if there are multiple pages, we will decode each page separately
// and return the results from all pages
const results = (await Promise.all(pageCanvas.map(async (canvas) => {
await yieldToBrowser('decodeFromCanvas');
return await decodeFromCanvas(canvas);
})))
await yieldToBrowser('decodeFromCanvas');
return await decodeFromCanvas(canvas);
})))
// remove null results (pages with no PDF417 codes)
.filter((result) => result !== null)
// flatten the array of arrays into a single array
.flat();
.flat() as DecodeResult[];
return(results);
default: