You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The import * approach works with the default TypeScript settings, but it's probably a good idea to enable TypeScript's --esModuleInterop setting, which changes the import behavior to be the same as various other tools. In that case, you'd write it as import cn from 'classnames';.
Example module classnames@2.2.5, see JedWatson/classnames#105.
In typescript, we use
import * as cn from 'classnames'
to import from module without default export.This gets transpiled using babel's
_interopRequireDefault
toresulting in
cn
equal to{ default: classNames() }
instead ofclassNames()
function, and throwingUncaught TypeError: cn is not a function
.Is there any way to fix it and handle such exports correctly?
The text was updated successfully, but these errors were encountered: