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
But I think this is incorrect. In this case math is undefined because there is no default export. The correct import would be:
import*asmathfrom'lib/math';
or if you wanted to just destructure:
import{pi,sum}fromMath;
I made this mistake today when dealing with code that was mixed with requires and import. These two statements below look equivalent because they similar structure which I think leads to the confusion:
I believe the module docs are incorrect. Based on this
lib/math.js
The docs say we can import like this
But I think this is incorrect. In this case math is
undefined
because there is no default export. The correct import would be:or if you wanted to just destructure:
I made this mistake today when dealing with code that was mixed with requires and import. These two statements below look equivalent because they similar structure which I think leads to the confusion:
There's a great reference here: http://www.2ality.com/2014/09/es6-modules-final.html for anyone who happens to come across this issue.
The text was updated successfully, but these errors were encountered: