imaskjs icon indicating copy to clipboard operation
imaskjs copied to clipboard

TSC fails to import types into non-ECMAScript module projects

Open marksmccann opened this issue 8 months ago • 0 comments

Describe the bug When react-imask is imported into a project that does not explicitly support ECMAScript modules view the "type" property, the TSC error ts(1479) is triggered and the types do not load.

Screenshot 2024-06-15 at 10 35 33 AM

To Reproduce Install v7.6.1 of react-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 the package.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:

  • OS: N/A
  • Browser: N/A
  • Version: N/A
  • IMask version: v7.6.1
  • Framework/plugin version: N/A

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.

marksmccann avatar Jun 15 '24 16:06 marksmccann