unplugin / unplugin-vue2-script-setup

💡 Bring `<script setup>` to Vue 2.
MIT License
599 stars 39 forks source link

Property 'setup' does not exist on type '{}' #118

Closed Rasool-deldar closed 2 years ago

Rasool-deldar commented 2 years ago

Hello, good morning, I'm sorry, I installed your package for Laravel-Mix according to the instructions, but unfortunately, the typing script gives the following error : Property 'setup' does not exist on type '{}'. node -v 16. * vue 2.6.14 typescript: 4.5.5 @ vue / composition-api -v 1.4.6 @ vue / runtime-dom -v 3.2.31 unplugin-vue2-script-setup -v 0.9.3

// laravel-mix mix.webpackConfig({ plugins: [ ScriptSetup({ }), ]});

{
    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "moduleResolution": "node",
        "strict": false,
        "noImplicitAny": false,
        "jsx": "preserve",
        "sourceMap": true,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "lib": [
            "esnext",
            "dom"
        ],
        "types": [
            "@types/node",
            "unplugin-vue2-script-setup/types"
        ],
        "baseUrl": ".",
        "paths": {
            "@/*": [
                "resources/scripts/*"
            ],
        }
    },
    "vueCompilerOptions": {
      "experimentalCompatMode": 2
    },
    "include": [
        "*.js",
        "*.js",
        ".*.js",
        "*.ts",
    ],
    "exclude": [
        "node_modules",
        "vendor",
        "public",
    ]
}
mengyouhan commented 2 years ago

me too. if my ts-loader options transpileOnly is false my tsconfig

    "types": [
      "unplugin-vue2-script-setup/types",
      "unplugin-vue2-script-setup/ref-macros"
    ],
mengyouhan commented 2 years ago

@Rasool-deldar try ts-loader options transpileOnly be true and use ForkTsCheckerWebpackPlugin to check ts in webpack config

{
            loader: 'ts-loader',
            options: {
               transpileOnly: true,
            }
          }
  plugins: [
  new ForkTsCheckerWebpackPlugin(
      {
        typescript: {
          extensions: {
            vue: {
              enabled: true,
              compiler: '@vue/compiler-sfc'
            }
          },
          diagnosticOptions: {
            semantic: true,
            syntactic: false
          }
        }
      }
    )
]
Rasool-deldar commented 2 years ago

@Rasool-deldar try ts-loader options transpileOnly be true and use ForkTsCheckerWebpackPlugin to check ts in webpack config

{
            loader: 'ts-loader',
            options: {
               transpileOnly: true,
            }
          }
  plugins: [
  new ForkTsCheckerWebpackPlugin(
      {
        typescript: {
          extensions: {
            vue: {
              enabled: true,
              compiler: '@vue/compiler-sfc'
            }
          },
          diagnosticOptions: {
            semantic: true,
            syntactic: false
          }
        }
      }
    )
]

Thank you for your help.