Skip to content

Commit

Permalink
fix nullability of style arguments of geometry methods (#3215)
Browse files Browse the repository at this point in the history
fixes #3034
  • Loading branch information
HackbrettXXX authored Sep 8, 2021
1 parent 0ea7418 commit a86d6ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
26 changes: 19 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ declare module "jspdf" {
height: number,
matrix: any
): jsPDF;
circle(x: number, y: number, r: number, style: string): jsPDF;
circle(x: number, y: number, r: number, style?: string | null): jsPDF;
clip(rule?: "evenodd"): jsPDF;
discardPath(): jsPDF;
deletePage(targetPage: number): jsPDF;
Expand All @@ -721,7 +721,7 @@ declare module "jspdf" {
y: number,
rx: number,
ry: number,
style?: string
style?: string | null
): jsPDF;
endFormObject(key: any): jsPDF;
f2(number: number): string;
Expand All @@ -744,13 +744,19 @@ declare module "jspdf" {
getStyle(style: string): string;
getTextColor(): string;
insertPage(beforePage: number): jsPDF;
line(x1: number, y1: number, x2: number, y2: number): jsPDF;
line(
x1: number,
y1: number,
x2: number,
y2: number,
style?: string | null
): jsPDF;
lines(
lines: any[],
x: any,
y: any,
scale?: any,
style?: string,
style?: string | null,
closed?: boolean
): jsPDF;
clip(): jsPDF;
Expand Down Expand Up @@ -791,7 +797,13 @@ declare module "jspdf" {
): boolean;
pdfEscape(text: string, flags: any): string;
path(lines?: any[], style?: string): jsPDF;
rect(x: number, y: number, w: number, h: number, style?: string): jsPDF;
rect(
x: number,
y: number,
w: number,
h: number,
style?: string | null
): jsPDF;
restoreGraphicsState(): jsPDF;
roundedRect(
x: number,
Expand All @@ -800,7 +812,7 @@ declare module "jspdf" {
h: number,
rx: number,
ry: number,
style: string
style?: string | null
): jsPDF;
save(filename?: string, options?: { returnPromise?: boolean }): jsPDF;
saveGraphicsState(): jsPDF;
Expand Down Expand Up @@ -867,7 +879,7 @@ declare module "jspdf" {
y2: number,
x3: number,
y3: number,
style: string
style?: string | null
): jsPDF;
getHorizontalCoordinateString(value: number): number;
getVerticalCoordinateString(value: number): number;
Expand Down
11 changes: 11 additions & 0 deletions types/jspdf-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,3 +638,14 @@ function test_addImageWithEncryption() {
height: 100
});
}

function test_nullStyleArgument() {
const doc = new jsPDF();
doc.rect(0, 0, 0, 0, null);
doc.roundedRect(0, 0, 0, 0, 0, 0, null);
doc.line(0, 0, 0, 0, null);
doc.triangle(0, 0, 0, 0, 0, 0, null);
doc.lines([], 0, 0, 0, null, false);
doc.ellipse(0, 0, 0, 0, null);
doc.circle(0, 0, 0, null);
}

0 comments on commit a86d6ce

Please sign in to comment.