-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
TSC fails to import types into non-ECMAScript module projects #1050
Comments
hi, sorry for long delay. |
Thanks for the reply. Unfortunately, I can't let this one go. If this is not resolved, our team will not be able to upgrade to the latest major version – unless we want to lose all the benefits of TypeScript. I'll put together a PR with some suggested changes that would resolve this issue. We can continue the conversation over there. |
I do not seem to have authority to reopen the issue (which makes sense). Please reopen this issue pending my PR. |
In order to work correctly, there should be separate types for esm and cjs bundles. Something like that:
There is no need to remove Also, You can check types by |
Thank you for sharing a link to that tool. It validates my point. The types are not being resolved properly for |
Yes, it shows that there are issue with packages. But the removing A good (and recommended by TypeScript authors) solution is specifying You can also do not specify "types" in "exports" field. TypeScript find types automatically if
With file structure:
To get rid of cjs-files we can add empty
But having separate |
Fair enough. If there is a better way to resolve the issue, then great! But, can we now agree that this is a valid problem that needs to be resolved? Will you reopen the issue? |
@uNmAnNeR it is still a issue. |
Describe the bug
When
react-imask
is imported into a project that does not explicitly support ECMAScript modules via the "type" property, the TSC errorts(1479)
is triggered and the types do not load.To Reproduce
Install
v7.6.1
ofreact-imask
into a CommonJS project (either by setting "type" to "commonjs" or by omitting the property altogether) and attempt to import the dependency.Expected behavior
The
imask
packages should support both CommonJS and ECMAScript modules. This can be done by omitting the "type" property from thepackage.json
. As far as I can tell, this is what all packages intended for browser consumption do. I have yet to find an exception to this rule. For example, popular packages like "react" and "@testing-library/dom" omit the "type" property, I assume, for the aforementioned reasons. FWIW, this is also what I have done for packages that I've built and distributed.Environment:
v7.6.1
Additional context
FYI, as one might assume, this is a blocker for our team. We will not be able to upgrade to v7 until this is resolved.
The text was updated successfully, but these errors were encountered: