Skip to content

docs: narrow clipboardItem.getType() return type from its MIME type - #54300

Merged
MarshallOfSound merged 2 commits into
mainfrom
docs/clipboard-item-gettype-narrowing
Sep 25, 2026
Merged

MarshallOfSound merged 2 commits into
mainfrom
docs/clipboard-item-gettype-narrowing

Conversation

@claude

@claude claude Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Requested by John Kleinschmidt · Slack thread

Description of Change

clipboardItem.getType() currently resolves to Blob | ClipboardBookmark for every MIME type except the bookmark literal, so callers reading ordinary types like text/html have to narrow with instanceof Blob even though the result can only be a Blob. This documents getType with a generic MIME type parameter and a conditional return type, so the bookmark literal gives a ClipboardBookmark, any other literal gives a Blob, and a plain string still gives the union, and it adds ts-smoke cases for all three and drops the now-unneeded narrowing from the text/uri-list example. It also bumps @electron/docs-parser to 3.0.2 for the parenthesized-union fix from electron/docs-parser#208.

Checklist

Release Notes

Notes: Improved TypeScript types for clipboardItem.getType() to narrow by MIME type.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9


Generated by Claude Code

Type getType() with a generic MIME type parameter and a conditional
return type so a literal `electron application/bookmark` resolves to a
ClipboardBookmark, any other literal MIME type resolves to a Blob, and
a non-literal string still resolves to the union. Adds ts-smoke cases
for all three and drops the now-unneeded `instanceof Blob` check from
the `text/uri-list` example.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9
@electron-cation electron-cation Bot added documentation 📓 semver/patch backwards-compatible bug fixes labels Sep 24, 2026
@claude claude Bot added target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 24, 2026
@claude
claude Bot marked this pull request as ready for review September 24, 2026 16:53
@socket-security

socket-security Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​electron/​docs-parser@​3.0.1 ⏵ 3.0.288 +810087 +188 +3100

View full report

@socket-security

socket-security Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

View full report

@claude

claude Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

The "Socket Security: Pull Request Alerts" check is failing on a single Block alert, "Recently published", for @electron/[email protected]. That version is the docs-parser release containing electron/docs-parser#208 that this PR bumps to. Our own release workflow published it at 17:52 UTC, a couple of minutes before the scan ran, and nothing else in the dependency diff is flagged. A maintainer can clear it with @SocketSecurity ignore npm/@electron/[email protected]. I haven't posted that myself because it waives a security gate.


Generated by Claude Code

@jkleinsc

Copy link
Copy Markdown
Member

@SocketSecurity ignore npm/@electron/[email protected]

@MarshallOfSound
MarshallOfSound merged commit 70d678d into main Sep 25, 2026
75 checks passed
@release-clerk

release-clerk Bot commented Sep 25, 2026

Copy link
Copy Markdown

Release Notes Persisted

Improved TypeScript types for clipboardItem.getType() to narrow by MIME type.

@MarshallOfSound
MarshallOfSound deleted the docs/clipboard-item-gettype-narrowing branch September 25, 2026 03:01
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "45-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "44-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/45-x-y needs-manual-bp/44-x-y and removed target/45-x-y PR should also be added to the "45-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

claude[bot] has manually backported this PR to "44-x-y", please check out #54342

@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

claude[bot] has manually backported this PR to "45-x-y", please check out #54343

MarshallOfSound pushed a commit that referenced this pull request Sep 25, 2026
…54343)

docs: narrow clipboardItem.getType() return type from its MIME type (#54300)

* docs: narrow clipboardItem.getType() return type from its MIME type

Type getType() with a generic MIME type parameter and a conditional
return type so a literal `electron application/bookmark` resolves to a
ClipboardBookmark, any other literal MIME type resolves to a Blob, and
a non-literal string still resolves to the union. Adds ts-smoke cases
for all three and drops the now-unneeded `instanceof Blob` check from
the `text/uri-list` example.


Claude-Session: https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9

* build: bump @electron/docs-parser to 3.0.2


Claude-Session: https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9

---------


(cherry picked from commit 70d678d)


Claude-Session: https://claude.ai/code/session_01A6qgQ8Q6Q5rwKtmambSd9V

Co-authored-by: Claude <[email protected]>
@trop trop Bot added merged/45-x-y PR was merged to the "45-x-y" branch. and removed in-flight/45-x-y labels Sep 25, 2026
MarshallOfSound pushed a commit that referenced this pull request Sep 25, 2026
…54342)

docs: narrow clipboardItem.getType() return type from its MIME type (#54300)

* docs: narrow clipboardItem.getType() return type from its MIME type

Type getType() with a generic MIME type parameter and a conditional
return type so a literal `electron application/bookmark` resolves to a
ClipboardBookmark, any other literal MIME type resolves to a Blob, and
a non-literal string still resolves to the union. Adds ts-smoke cases
for all three and drops the now-unneeded `instanceof Blob` check from
the `text/uri-list` example.


Claude-Session: https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9

* build: bump @electron/docs-parser to 3.0.2


Claude-Session: https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9

---------


(cherry picked from commit 70d678d)


Claude-Session: https://claude.ai/code/session_01A6qgQ8Q6Q5rwKtmambSd9V

Co-authored-by: Claude <[email protected]>
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y documentation 📓 merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants