imaskjs
imaskjs copied to clipboard
TSC fails to import types into non-ECMAScript module projects
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.
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.