As of 2026, this repository is archived and read-only.
With Vue 2 reaching End of Life (EOL) and the rise of powerful AI coding assistants, we are no longer actively maintaining this tool.
Yes, but as a "First Pass" tool.
While AI (Cursor, Copilot, ChatGPT) is excellent at fixing logic and types, it can be slow and expensive for bulk syntax conversion across hundreds of files. This tool remains the most efficient way to handle the deterministic "heavy lifting" of converting Class syntax to Composition API.
- Bulk Convert: Run
vue-class-migratoron your codebase to instantly transform the syntax structure (Decorators, Data, Methods ->defineComponent/setup). - AI Refinement: Use AI tools to handle the "last mile":
- Fixing TypeScript errors.
- Refactoring complex logic inside
setup(). - Migrating obscure edge cases this tool might miss.
(The original documentation follows below)
Vue Class Migrator is a utility designed to facilitate the migration of Vue and TypeScript files using the @component decorator from vue-class-components to the defineComponent format. Under the hood, it employs ts-morph for parsing and generating files.
You can install vue-class-migrator globally using npm:
npm install -g vue-class-migratorAccepted options
- -d: Specifies the directory you want to migrate.
- --sfc: (Optional flag, default: false) Removes original TS and style files, generating a final Vue Single File Component (SFC).
npm run migrate -- -d <your_path>
The tool also migrates decorators from vuex-class and vue-property-decorator.
If the tool encounters unsupported code in your class, it will produce errors. Monitor the output and verify the generated file. In such cases, you can contribute to the migrator to add support or correct the file manually.
Initially, avoid using --sfc directly.
First, run the tool without it and compare the changes in the TS files using version control. If satisfied, discard the changes and rerun with --sfc.
In addition to migrating the class to the defineComponent format, vue-class-migrator also migrates the following libraries out of the box.
| Decorator | Support |
|---|---|
| @State | ❌ Not yet |
| @Getter | ✅ |
| @namespace.Getter | ❌ Not yet |
| @Action | ✅ |
| @Mutation | ✅ |
| Decorator | Support |
|---|---|
| @Prop | ✅ |
| @PropSync | ✅ |
| @Model | ✅ |
| @ModelSync | ✅ |
| @Watch | ✅ |
| @Provide | ❌ Not yet |
| @Inject | ❌ Not yet |
| @ProvideReactive | ❌ Not yet |
| @InjectReactive | ❌ Not yet |
| @Emit | ❌ Not yet |
| @Ref | ✅ |
| @VModel | ❌ Not yet |
| @Component | ✅ |
| @Mixins | ✅ |
For security matters please contact [email protected].
Copyright 2023 GetYourGuide GmbH.
vue-class-migrator is licensed under the Apache License, Version 2.0. See LICENSE for the full text.