yoyo930021 / vc2c

The vc2c project can convert vue class APIs to vue composition APIs in Vue.js components written in Typescript.
https://yoyo930021.github.io/vc2c/
MIT License
87 stars 20 forks source link

feat: convert methods as function declaration #50

Closed imslepov closed 6 months ago

imslepov commented 6 months ago

I've added functionality to convert methods as function declaration.

For example, this code:

import Vue from 'vue'
import { Component } from 'vue-property-decorator'

@Component({})
export default class HelloWorld extends Vue {
  hello () {
    console.log('hello world')
  }
}

Will be converted into this:

export default defineComponent({
  name: 'HelloWorld',
  setup(props, context) {
    function hello() {
      console.log('hello world')
    }
    return { hello }
  },
})

And fixed a bug with method modifiers.