av-ts: Uncaught TypeError: Cannot call a class as a function @ v0.5.2 / v0.5.3

When with v0.5.1 it’s all good.

The error was caused here:

_classCallCheck(this, HelloComponent); // then

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

I compared the built code and the only difference is:

// v0.5.1 (working)

function decorate(cls) {
  Component.inDefinition = true;
  // workaround flow inference
  var instance = undefined;
  try {
    instance = new cls();
  }
  finally {
    Component.inDefinition = false;
  }
// v0.5.2 (broken)

function decorate(cls) {
  Component.inDefinition = true;
  var instance = Object.create(Vue.prototype);
  Object.defineProperty(instance, '_init', {
    value: util_1.NOOP, enumerable: false
  });
  try {
    cls.call(instance); // this calls _classCallCheck
  }
  finally {
    Component.inDefinition = false;
  }

I’m using vue@2.0.5, vue-loader@9.9.1 I’m not using vue-ts-loader, but awesome-typescript-loader and separated template like below:

<style lang="sass" src="./app.component.sass" />
<template lang="pug" src="./app.component.pug" />
<script lang="ts" src="./app.component.ts" />
import { Vue, Component } from 'av-ts'

@Component({
  name: 'app',
})
export default class AppComponent extends Vue {
}

I’ve put my code here: https://github.com/whitetrefoil/vue-ts-arch/tree/av-ts-052

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (17 by maintainers)

Most upvoted comments

Fixed in 0.5.4