parallax/jsPDF

`getTextDimension` has incorrect type definition

chakflying opened this issue · 1 comments

According to the code, the function should be able to handle input of type string, array of strings or number.

jsPDF/src/modules/cell.js

Lines 191 to 197 in f60dcfa

if (!Array.isArray(text) && typeof text !== "string") {
if (typeof text === "number") {
text = String(text);
} else {
throw new Error(
"getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings."
);

However, the type definition does not reflect this.

jsPDF/types/index.d.ts

Lines 1051 to 1053 in f60dcfa

getTextDimensions(
text: string,
options?: {

I also took a quick look at splitTextToSize() and it seems quite likely that the return type is string[]. I can help fix that as well if needed.