Skip to content

getTextDimension has incorrect type definition #3799

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

Closed
chakflying opened this issue Nov 22, 2024 · 1 comment
Closed

getTextDimension has incorrect type definition #3799

chakflying opened this issue Nov 22, 2024 · 1 comment

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.

Copy link

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant