ts-mixer: ES6 compile target causes "Cannot call class as function" error

Our project use babel-typescript-plugin as compiler, in generated code, here is:

function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a function");
    }
  }

I see that ts-mixer call constructor explicitly.

See https://github.com/babel/babel/issues/700#issuecomment-73180719

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

v3.0.0 has been released, which should resolve this issue.

Oh shoot, you’re right… That might be impossible to get around too. The super call issue could be worked around because you can access the superclass constructor directly with Object.getPrototypeOf(SubClass.prototype).contructor, but closures are a whole different problem. I’ll have to rethink my approach and/or give the Proxy option a closer look.