Skip to content

Commit

Permalink
Merge pull request #38 from robertknight/convert-attype-tags
Browse files Browse the repository at this point in the history
Convert remaining @type tags to TS syntax
  • Loading branch information
robertknight authored Jun 5, 2022
2 parents ab7a7e8 + e73b25f commit a08611e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/ocr-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export class OCRClient {
const worker = createWorker(workerURL);
this._worker = worker;

/** @type {ProgressListener[]} progress */
this._progressListeners = [];
this._progressListeners = [] as ProgressListener[];

const endpoint =
"addEventListener" in worker ? worker : nodeEndpoint(worker);
Expand Down
6 changes: 2 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Extract the pixel data from an ImageBitmap.
*/
export function imageDataFromBitmap(bitmap: ImageBitmap): ImageData {
/** @type {HTMLCanvasElement} */
let canvas;
let canvas: HTMLCanvasElement;
// @ts-expect-error - OffscreenCanvas API is missing
if (typeof OffscreenCanvas !== "undefined") {
// @ts-expect-error - OffscreenCanvas API is missing
Expand All @@ -17,8 +16,7 @@ export function imageDataFromBitmap(bitmap: ImageBitmap): ImageData {
throw new Error("No canvas implementation available");
}

const context =
/** @type {CanvasRenderingContext2D} */ canvas.getContext("2d");
const context = canvas.getContext("2d") as CanvasRenderingContext2D;
context.drawImage(bitmap, 0, 0, bitmap.width, bitmap.height);
return context.getImageData(0, 0, bitmap.width, bitmap.height);
}

0 comments on commit a08611e

Please sign in to comment.