Skip to content

fix(types): make downloadImage opts optional - #8080

Open
Yahiro025 wants to merge 3 commits into
plotly:mainfrom
Yahiro025:fix/download-image-opts-optional-8072
Open

Yahiro025 wants to merge 3 commits into
plotly:mainfrom
Yahiro025:fix/download-image-opts-optional-8072

Conversation

@Yahiro025

Copy link
Copy Markdown

Summary

Make opts optional on Plotly.downloadImage so the TypeScript signature matches runtime behavior and Plotly.toImage.

Fixes #8072

Why

src/snapshot/download.js does opts = opts || {}, so Plotly.downloadImage(gd) is valid at runtime. After #8066, toImage marks opts optional, but downloadImage still required it and broke type-checking for the one-argument call.

Change

In src/types/core/api.d.ts:

export function downloadImage(root: RootOrData, opts?: DownloadImgopts): Promise<string>;

Types only. No runtime change.

Tests

Types-only change. No jasmine suite covers .d.ts signatures. Runtime one-arg behavior is already covered by existing download tests and by opts = opts || {} in src/snapshot/download.js.

Checklist notes

Runtime downloadImage treats a missing opts as {}.
toImage already marks opts optional; align downloadImage.

Fixes plotly#8072

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Could you please remove the draftlog? We don't need one for such a small update.

Co-authored-by: Bennett Payoyo <Yahiro025@users.noreply.github.com>
@Yahiro025

Copy link
Copy Markdown
Author

@camdecoster Removed the draftlog as requested — typings-only change remains.

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 this pull request may close these issues.

[BUG]: incorrect downloadImage type definition

2 participants