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

fix nullability of style arguments of geometry methods #3215

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}