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

Typescript does not allow null for style parameter in rect() #3034

Closed
bmckilligan opened this issue Dec 11, 2020 · 4 comments · Fixed by #3215
Closed

Typescript does not allow null for style parameter in rect() #3034

bmckilligan opened this issue Dec 11, 2020 · 4 comments · Fixed by #3215

Comments

@bmckilligan
Copy link

when trying to create a clipping rectangle using rect(x, y, w, h, style) with style = null
typescript definition is showing null as an invalid argument option

using rect(x, y, w, h) or rect(x, y, w, h, undefined) does not create the proper clipping rectangle

changing line 722 in jsPDF/types/index.d.ts seams to work
from:
rect(x: number, y: number, w: number, h: number, style?: string): jsPDF;
to:
rect(x: number, y: number, w: number, h: number, style?: string | null ): jsPDF;

@HackbrettXXX
Copy link
Collaborator

I agree. Could you prepare a pull request? Also change the other shape methods accordingly.

Tip: when switching to advancedAPI, the style parameter is truly optional, and you can fill/stroke with the clip/stroke etc. methods.

@bmckilligan
Copy link
Author

using the advancedAPI still doesn't seam to resolve the issue with clipping, I have been trying

doc.advancedAPI((d) => { d.rect(a,y,w,h); });

I don't have time at the moment to go through and fix the other shape methods and create the tests etc... I am not familiar with the code base

@bmckilligan
Copy link
Author

Is this fix going to make it in index.d.ts?

@HackbrettXXX
Copy link
Collaborator

If someone from the community creates a pull request, yes. I currently don't have the time to fix this myself.

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.

2 participants