-
Notifications
You must be signed in to change notification settings - Fork 563
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
Not compatible with TypeScript #205
Comments
The Line 15 in 5d971e4
Which error does typescript report if you do |
It does not throw an error in this case. As well it does not throw an error for As a result - the main problem here is However, However, the current So, long story short - no, this ain't going to work. |
the |
Seems
or the workaround is just to use |
Waiting on #177 |
The current version of classnames is not exposing
default
in a ESM format, as well asd.ts
has no mention of it. As a resultimport * as cx from 'classnames'
, is a correct way to load this module from a TypeScript perspective.However, if the result code would be compiled down using Babel, and Babel can compile TypeScript this would lead to the runtime exception -
cx is not an object
The reason is
_interopRequireWildcard
helper, which would convertclassnames
to the{default: classnames}
, which is yet - not a function.While webpack is managing "harmony imports" by it's own, and managing in a correct (from TypeScript point of view) way -
import *
==module.exports
, babel is more ESM modules compatible, and wildcard import is working differently in that case.Proposal:
classnames
to contain_esModule
property to make it ESM compatible.d.ts
to contain only default export (breaking change), to resolve this issue.See babel/babel#10574 (comment) for details.
The text was updated successfully, but these errors were encountered: