Repository navigation
docs: narrow clipboardItem.getType() return type from its MIME type - #54300
Conversation
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
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HmVsAQiHawruFHijTtkzV9
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
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:
|
|
The "Socket Security: Pull Request Alerts" check is failing on a single Block alert, "Recently published", for Generated by Claude Code |
|
@SocketSecurity ignore npm/@electron/[email protected] |
|
Release Notes Persisted
|
|
I was unable to backport this PR to "45-x-y" cleanly; |
|
I was unable to backport this PR to "44-x-y" cleanly; |
|
claude[bot] has manually backported this PR to "44-x-y", please check out #54342 |
|
claude[bot] has manually backported this PR to "45-x-y", please check out #54343 |
…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]>
…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]>
Requested by John Kleinschmidt · Slack thread
Description of Change
clipboardItem.getType()currently resolves toBlob | ClipboardBookmarkfor every MIME type except the bookmark literal, so callers reading ordinary types liketext/htmlhave to narrow withinstanceof Blobeven though the result can only be a Blob. This documentsgetTypewith a generic MIME type parameter and a conditional return type, so the bookmark literal gives aClipboardBookmark, any other literal gives aBlob, and a plainstringstill gives the union, and it adds ts-smoke cases for all three and drops the now-unneeded narrowing from thetext/uri-listexample. It also bumps@electron/docs-parserto 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