node.js - Why does object exported in ES6 module have undefined methods? -
i have es6 class defined in es6 module exports instance of class:
class myobject {   constructor() {     this.propertya = 1;     this.propertyb = 2;   }    mymethod() {     dostuff();   } }  var theinstance = new myobject(); export default theinstance;   when import module, mymethod undefined:
import * theobject './my/module';  theobject.mymethod(); // error! undefined not method.   the properties defined in constructor do exist. it's though object's prototype excluded, , members exported.
i requiring 'babel/register'.
why exporting object not working correctly?
i figured out right after asking. looks there's difference between import * foo 'module' , import foo 'module'. works:
import theobject './mymodule';   so wasn't matter of wrong thing being exported, being imported incorrectly.
Comments
Post a Comment