unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

<script setup lang="ts"> cannot find name 'onMounted'

mariusa opened this issue · comments

onMounted works fine for <script setup> with vscode, no warnings.
.eslintrc has

extends: ["eslint:recommended", "plugin:vue/base", "plugin:vue/vue3-essential", "plugin:vue/vue3-recommended", "plugin:vue/vue3-strongly-recommended", "@antfu"],

Adding lang="ts" makes vscode show warning cannot find name 'onMounted', but $ref has no warning.

How to solve this?

Maybe related to #61 ?

We temporarily close this due to the lack of enough information. Please provide a minimal reproduction to reopen the issue. Thanks.

Looking at vitesse (thanks for it), found the solution: Add to AutoImport in vite config:

dts: 'src/auto-imports.d.ts',

for me, it has fixed the problem: add *.d.ts to tsconfig.json

  // tsconfig.json
  "include": [
    "*.d.ts",
    "src/**/*.ts",
    "src/**/*.d.ts",
    "src/**/*.tsx",
    "src/**/*.vue"
  ],