fix: ignore export assign cannot be used in module TS error, fixes #1018 #1022
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #1018
Summary
Fixes issue #1018 by simply ignoring the TypeScript error since the TS error has no negative effect whatsoever on the functionality of these types. This makes TypeScript and "Are the Types Wrong" both happy and everything is back to normal and we can get back to work (finally).
The quick explanation is that sometime even when using ESM imports, CJS types exports get picked up (depending on the users tsconfig module resolutions) and
export = ...
is a TypeScript error, but we can easily patch it by ignoring it.Background & Context
I found this article Default exports in CommonJS libraries which explains why
export = _default
was patched in the first place. However this gives a TypeScript error in some cases (depending on your tsconfig module resolutions and other configs), this error can simply be ignored altogether because the types still work correctly, the error when active though will block a TypeScript build, however simply ignoring the error will let us continue with our build successfully.Tasks
I simply modified the existing
fix-cjs-types.js
script and ran a build.This also keeps "Are the Types Wrong" happy since nothing really changed for the types themselves, so all is good and we're all happy 🎉
Dependencies