Hi I am new to JS and Node.
I have this class
foo.mjs
class Foo extends BarInterface { constructor(configFilePath) { super(); this.type = 'mytype'; this.name = 'foo'; } name() { return this.name; } type() { return this.type; } } ... export default new Foo(configFilePath);
in manager.mjs I import foo
import foo from './foo/foo.mjs'; class Manager { constructor(memberList){ this.registry = {} memberList.forEach(d => { this.register(d); }); } register(m) { if (!m instanceof BarInterface) { throw new Error(`${m} must have implement BarInterface`); } this.deviceHandlers[m.type()] = m; <------------HERE I SEE AN ERROR } }
above when I call m.type() is telling me that TypeError: foo.type is not a function
but type() is defined in the class in foo.mjs? whats going on here?
没有评论:
发表评论