Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTextDimension has incorrect type definition #3799

Open
chakflying opened this issue Nov 22, 2024 · 0 comments · May be fixed by #3800
Open

getTextDimension has incorrect type definition #3799

chakflying opened this issue Nov 22, 2024 · 0 comments · May be fixed by #3800

Comments

@chakflying
Copy link

chakflying commented Nov 22, 2024

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.

@chakflying chakflying linked a pull request Nov 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant