vuejs / vue-class-component

ES / TypeScript decorator for class-style Vue components.
MIT License
5.81k stars 429 forks source link

Bug: can't call super on an extended class #560

Open xmorelll opened 3 years ago

xmorelll commented 3 years ago

version: 7.2.6

I have a class that extends from another one. Something similar to: https://class-component.vuejs.org/guide/extend-and-mixins.html#extend

// super.js
import Vue from 'vue'
import Component from 'vue-class-component'

// Define a super class component
@Component
class Super extends Vue {
  protected fo() {
    return "Super";
  }
}
import Super from './super'
import Component from 'vue-class-component'

// Extending the Super class component
@Component
export default class HelloWorld extends Super {
  created() {
    console.log(this.fo());
  }

  protected fo() {
    return super.fo() + " HelloWorld";
  }
}

On the console.log() I would expect "Super HelloWorld", instead I found a JS error;

index.js:56 TypeError: (intermediate value).fo is not a function
    at VueComponent.fo

Here the link with a jsfiddle to reproduce this case. https://jsfiddle.net/ouk9nt1d/