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

semantic error TS2339: Property 'write' does not exist on type 'Clipboard' -- can't repro #306

Closed
wamujlb opened this issue Mar 29, 2022 · 3 comments
Labels
kind: support Asking for support with something or a specific use case problem: needs more info This issue needs more information in order to handle it problem: no repro No reproduction was provided (and have not tried to repro without one) problem: removed issue template OP removed the issue template without good cause problem: stale Issue has not been responded to in some time solution: can't repro An attempt to reproduce has been tried and failed solution: workaround available There is a workaround available for this issue topic: TS version Related to a change in a TS version

Comments

@wamujlb
Copy link

wamujlb commented Mar 29, 2022

What happens and why it is wrong

(rpt2 plugin) Error: ../...tsx(48,34): semantic error TS2339: Property 'write' does not exist on type 'Clipboard'.

I'm trying to use clipboard.write API but it throws an error on compilation.

Environment

Node 16

Versions
npmPackages:
    typescript: ^4.5.5 => 4.6.2
    rollup-plugin-typescript2: ^0.31.2

tsconfig.json

`tsconfig.json`:
{
  "compilerOptions": {
    "outDir": "dist",
    "module": "esnext",
    "target": "ESNext",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "jsx": "react",
    "sourceMap": true,
    "declaration": true,
    "esModuleInterop": true,
    "downlevelIteration": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowSyntheticDefaultImports": true,
    "typeRoots": ["node_modules/@types", "src/lib-types"],
    "types": ["resize-observer-browser"]
  },
  "include": ["src", "scripts"],
  "exclude": ["node_modules", "dist", "example"],
  "paths": {
    "@src/*": ["./src/*"],
    "@types/*": ["./src/types"],
    "@components/*": ["./components/*"]
  }
}
@agilgur5
Copy link
Collaborator

Does tsc throw the same error or no?

@agilgur5 agilgur5 changed the title (rpt2 plugin) Error: ../...tsx(48,34): semantic error TS2339: Property 'write' does not exist on type 'Clipboard'. semantic error TS2339: Property 'write' does not exist on type 'Clipboard' Apr 23, 2022
@agilgur5 agilgur5 added the problem: needs more info This issue needs more information in order to handle it label Apr 23, 2022
@agilgur5
Copy link
Collaborator

You didn't provide a full code example, but if you mean the navigator.clipboard API, it appears that write was added to the DOM TS standard typings in microsoft/TypeScript#44842 and released along with TS 4.4 as far as I can tell.

So if tsc doesn't throw the same error, then I would think you may have a TS version mismatch and may need to pass the typescript option into this plugin.

Alternatively, you could also use @types/dom-clipboard-api

Per the MDN doc linked above, this seems to be a pretty new feature (writeText is a little older), and not fully supported or allowed on all browsers in all contexts.

@agilgur5 agilgur5 added solution: workaround available There is a workaround available for this issue problem: removed issue template OP removed the issue template without good cause problem: no repro No reproduction was provided (and have not tried to repro without one) topic: TS version Related to a change in a TS version labels Apr 24, 2022
@agilgur5 agilgur5 added the problem: stale Issue has not been responded to in some time label May 15, 2022
@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case solution: can't repro An attempt to reproduce has been tried and failed labels Jun 8, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Jun 8, 2022

I created a minimal reproduction here and was unable to reproduce this error.

Both tsc and rpt2 do not give this error in their latest versions (4.7.3 for TS, 0.32.1 for rpt2).

So the error you're getting is likely due to a problem in your environment, and not a bug in rpt2.

@agilgur5 agilgur5 closed this as completed Jun 8, 2022
@agilgur5 agilgur5 changed the title semantic error TS2339: Property 'write' does not exist on type 'Clipboard' semantic error TS2339: Property 'write' does not exist on type 'Clipboard' -- can't repro Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case problem: needs more info This issue needs more information in order to handle it problem: no repro No reproduction was provided (and have not tried to repro without one) problem: removed issue template OP removed the issue template without good cause problem: stale Issue has not been responded to in some time solution: can't repro An attempt to reproduce has been tried and failed solution: workaround available There is a workaround available for this issue topic: TS version Related to a change in a TS version
Projects
None yet
Development

No branches or pull requests

2 participants