Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite-ts 不支持 unplugin-vue-components 插件自动生成的 components.d.ts #90

Open
seepine opened this issue Nov 18, 2023 · 1 comment

Comments

@seepine
Copy link

seepine commented Nov 18, 2023

vite.config.js

import Components from 'unplugin-vue-components/vite'

export default defineConfig({
  plugins: [
    uni(),
    Components({
      dirs: ['src/components']
    })
  ]
})

tsconfig.json

{
  "extends": "@vue/tsconfig/tsconfig.json",
  "compilerOptions": {
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "lib": ["esnext", "dom"],
    "ignoreDeprecations": "5.0"
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.d.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "*.d.ts"
  ]
}

components.d.ts

/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

declare module 'vue' {
  export interface GlobalComponents {
    MyNav: typeof import('./src/components/my-nav/my-nav.vue')['default']
    RouterLink: typeof import('vue-router')['RouterLink']
    RouterView: typeof import('vue-router')['RouterView']
  }
}

my-nav.vue

<template>
  <view class="bg-sky-500"> my-nav </view>
</template>

效果图
image

直接使用,没有提示
image

手动引用,才有提示
image

@FliPPeDround
Copy link

可以使用vite-plugin-uni-components代替,来解决这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants