无法扩展导入的类

时间:2018-02-02 23:48:01

标签: javascript

我正在尝试扩展导入的类,但在运行代码时出现以下错误:

class Help extends _commands.Command {
                             ^

TypeError: Class extends value undefined is not a constructor or null

这是包含错误生成子类的文件:

import {Command} from './../commands.js'
import * as cmdList from './index.js'

export class Help extends Command {
  constructor (msg) {
    super(msg)
    this.desc = 'Displays this help and exits'
  } 
  action () {
    let help = '```md\ Help\n===\nCommand list:\n'
    for (let cmd in cmdList) {
      help += `- !${cmd}: ${new cmdList[cmd](this.msg).desc}\n`
     }
     help += '```'
     this.sendMsg(help)
   }
}

以下是父类的文件:

import {cmdPrefix} from './index.js'
import {sendMsg} from './send-msg.js'
import {readData, updateUserData} from './data.js'
import * as cmdList from './cmds/index.js'

export class Command {
  constructor (msg) {
    this.id = msg.author.id
    this.msg = msg
  }
  action () {}
  get data () {
    return readData().user[this.id]
  }
  updateUserData (key, val) {
    updateUserData(this.id, key, val)
  }
  sendMsg (data) { 
    sendMsg(this.msg, data)
  }
}

如果需要,将提供更多信息。

0 个答案:

没有答案
相关问题