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

Type "clipboard-write" is not assignable to type "PermissionName" #1245

Open
aminnairi opened this issue Jan 8, 2022 · 5 comments
Open

Type "clipboard-write" is not assignable to type "PermissionName" #1245

aminnairi opened this issue Jan 8, 2022 · 5 comments

Comments

@aminnairi
Copy link

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.

@saschanaz
Copy link
Contributor

saschanaz commented Jan 16, 2022

Clipboard permissions are at risk:

  1. clipboard-read is officially removed from the spec: Remove clipboard-read permission w3c/clipboard-apis#132
  2. clipboard-write has no multiple implementer interest and thus will probably be removed too: Should clipboard-write permission be removed too? w3c/clipboard-apis#163

And thus I think this won't be solved, at least not anytime soon.

@jordihm9
Copy link

jordihm9 commented May 30, 2022

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...

@fresonn
Copy link

fresonn commented Apr 25, 2023

Still relevant. Any updates?
Way to solve this problem:

navigator.permissions.query({ name: "clipboard-write" as PermissionName }).then(result => {});

@saschanaz
Copy link
Contributor

clipboard-write is still a Blink-only thing as of today.

@fresonn
Copy link

fresonn commented Apr 25, 2023

@saschanaz. Oh, I got it. An open issue misled me, I thought it was an error ...
Thanks

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

No branches or pull requests

4 participants