You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the return type for getRGBAData is listed as either Uint8Array or Uint8ClampedArray.
Though by default, with no arguments passed it will return Uint8Array, and only when the option {clamped: True} is passed will Uint8ClampedArray be returned, as stated by the docs.
Can the return type of the function in index.d.ts be updated to recognize this behavior, possibly using Function Overloads?
Reason being, recently I have used this library to first crop an image then add that image to a PDF, using jsPDF which expects the image to be a Uint8Array. Though because the type is listed as either or, typescript throws an error. I was forced to use the as keyword to manually tell typescript which type it was. Which is probably not the best solution long term.
Currently, the return type for
getRGBAData
is listed as eitherUint8Array
orUint8ClampedArray
.Though by default, with no arguments passed it will return
Uint8Array
, and only when the option{clamped: True}
is passed willUint8ClampedArray
be returned, as stated by the docs.Can the return type of the function in
index.d.ts
be updated to recognize this behavior, possibly using Function Overloads?Reason being, recently I have used this library to first crop an image then add that image to a PDF, using jsPDF which expects the image to be a
Uint8Array
. Though because the type is listed as either or, typescript throws an error. I was forced to use the as keyword to manually tell typescript which type it was. Which is probably not the best solution long term.image-js/index.d.ts
Line 72 in 9ab86a8
image-js/src/image/core/getRGBAData.js
Lines 3 to 15 in 9ab86a8
The text was updated successfully, but these errors were encountered: