-
Notifications
You must be signed in to change notification settings - Fork 99
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
Upgrade TypeScript and drop DOM global types #148
Conversation
TypeScript now ships with type definitions for clipboard globals in the DOM lib as of TypeScript 4.4. This fixes errors which can occur when trying to use clipboard-polyfill in combination with TypeScript 4.4 and newer, where there are conflicts between the two type definitions.
I guess this is what I sign up for with such a library. Thanks for making all these changes! I can't promise to look at it super soon, but I think TypeScript 4.4 support is still valuable even through this library is just for legacy compat at this point. I'll probably give |
Would you mind also sharing a repro where e.g. |
Sure, here's a sample repository: https://github.com/aduth/tmp-repro-clipboard-typescript It looks like the issue might be limited to the |
Alright, I gave it a go on this branch: https://github.com/lgarron/clipboard-polyfill/tree/typescript-4.5.5 I want to avoid requiring TypeScript 4.4, since the whole point of this project is (now) legacy compat. Could you let me know if that branch works for you? |
a4c4820
to
de72422
Compare
Thanks for taking a look at this so quickly. I tried checking out the new branch, though unfortunately I wasn't able to generate the type definitions due to the following errors:
|
ba6ef45
to
49dd676
Compare
Global augmentation in TypeScript is still troublesome. In particular, it's difficult to exclude (and therefore difficult to avoid compile errors) if it's available in a project or `node_modules`, even if not imported directly: - microsoft/TypeScript#37053 - #148
I've removed all global types in Please let me know if |
Hey @lgarron , thanks for picking this back up. I just tested and it appears that |
@lgarron I may have spoken too soon, as I'm seeing some errors about "No "exports" main defined in clipboard-polyfill/package.json". I assume it's not related to the TypeScript types though. I'll dig a bit more and see what I can find. Edit: I'm thinking this has to do with how the new version is ESM-only, and our project is still using CommonJS for our Mocha-based tests. If that's expected, maybe not an "issue" as much as me needing to upgrade our project. |
Hmm, I've removed the I don't plan to support non-ESM builds, though, so if that's the issue you'll have to adapt your stack. |
Alright, please see if |
@lgarron Thanks for that revision. I think it could make sense to include the I may try to see if I can get it working with dynamic |
Yeah, unfortunately we no longer provide CommonJS builds. I have some advice at https://github.com/lgarron/clipboard-polyfill#bundling--tree-shaking--minification--commonjs if you want to get a CommonJS build, although it might be easier for you to pin to |
TypeScript now ships with type definitions for clipboard globals in the DOM lib as of TypeScript 4.4. This pull request attempts to fix errors which can occur when trying to use
clipboard-polyfill
in combination with TypeScript 4.4 and newer, where there are conflicts between the two sets of type definitions.The proposed solution here is to remove the project's own type definitions, deferring instead to TypeScript built-in DOM types.
This could be considered a breaking change, as it would require the consuming project to use TypeScript 4.4 or newer and opt-in to DOM lib types.
Click to expand error