TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
Type "clipboard-write" is not assignable to type "PermissionName"
Description
When using the Clipboard API, one might need to request permission for the clipboard-write in case we want to add something to the user's system clipboard if the user didn't already yield the permission.
Issue
When providing the clipboard-write permission to the window.navigator.permissions.query({name: "clipboard-write"}); method, the compiler throws an error saying that Type "clipboard-write" is not assignable to type "PermissionName".
Reproduction code
window.navigator.permissions.query({name: "clipboard-write"});
Typescript version
4.5.4
Additional context
It looks like the clipboard-write and clipboard-read permissions are not listed in the lib.dom.d.ts file for the PermissionName type, although they are part of the standard Clipboard API.
Clipboard permissions are at risk:
- clipboard-read is officially removed from the spec: https://github.com/w3c/clipboard-apis/pull/132
- clipboard-write has no multiple implementer interest and thus will probably be removed too: https://github.com/w3c/clipboard-apis/issues/163
And thus I think this won't be solved, at least not anytime soon.
Hi!
So "officially" has been removed both clipboard-write and clipboard-read but in MDN Permissions API documentation they are already there? (even compatibility is not the best)
Also, I guess I can use navigator.clipboard.writeText() without requesting the user the permission?
Thank you.
EDIT:
Sorry, clipboard-write is not officially removed but is not detected as a Permission Name when using Typescript...
Still relevant. Any updates? Way to solve this problem:
navigator.permissions.query({ name: "clipboard-write" as PermissionName }).then(result => {});
clipboard-write is still a Blink-only thing as of today.
@saschanaz. Oh, I got it. An open issue misled me, I thought it was an error ... Thanks