Fix: Cannot Combine Flow and TypeScript Plugins in Vue.js

Error message:
Cannot combine flow and typescript plugins.
Compiler & Build 2025-01-25

What Causes This Error?

This error occurs when you try to enable both Flow and TypeScript parsers simultaneously in Vue’s compiler configuration. They are mutually exclusive type systems.

The Problem

// ❌ Both type systems enabled
{
  parserPlugins: ['typescript', 'flow']
}

The Fix

Choose One Type System

// ✅ TypeScript only (recommended)
{
  parserPlugins: ['typescript']
}

// ✅ Or Flow only
{
  parserPlugins: ['flow']
}

Vite Configuration

// vite.config.js
import vue from '@vitejs/plugin-vue'

export default {
  plugins: [
    vue({
      script: {
        // ✅ Use TypeScript
        babelParserPlugins: ['typescript']
      }
    })
  ]
}

Migrating from Flow to TypeScript

If you have Flow code and want to migrate:

# Install TypeScript
npm install -D typescript

# Convert Flow files
npx flow-to-ts src/**/*.js

Check Your Configuration

// Remove conflicting configuration
export default {
  plugins: [
    vue({
      script: {
        // Only one of these, not both
        babelParserPlugins: ['typescript'] // or ['flow']
      }
    })
  ]
}

Quick Checklist

  • Choose either TypeScript OR Flow, not both
  • Check Vite/webpack configuration for duplicate plugins
  • Migrate Flow to TypeScript if needed
  • TypeScript is the recommended choice for Vue 3