unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

如何配置指定名称的组件才在components.d.ts文件中生成类型声明

Open JackieCheung opened this issue 2 years ago • 9 comments

例如,有如下组件目录结构:

--component-a
----child-a.vue
----child-b.vue
----index.vue

这样index.vuechild-a.vuechild-b.vue都会生成类型声明,但实际上child-achild-b组件作为component-a组件的子组件,并不需要单独对外暴露的,而且child-a.vuechild-b.vue还有可能与其它组件重名,有没有办法只匹配到名字为index的组件才生成类型声明,尝试了include属性,好像没效果

JackieCheung avatar Jun 14 '22 15:06 JackieCheung

@JackieCheung

currently you can't do this Glob Scan does not filter files by include/exclude (they are settings for transform)

azaleta avatar Jun 29 '22 18:06 azaleta

I also want this feature because I don't want type declarations provided by Vue2 UI library (all the component types are any), I define the types of these components myself. While I still want unplugin-vue-components to generate other components' type for me.

kingyue737 avatar Jul 13 '22 08:07 kingyue737

I also want this feature too.

paul-xia avatar Nov 29 '22 07:11 paul-xia

您好,请问有解决办法了吗?我也有这个困惑

cx741041875 avatar Jan 10 '23 15:01 cx741041875

@lishaobos 大佬你这个pr怎么使用啊

nigiwen avatar Aug 03 '23 06:08 nigiwen

就是和 glob 规则一样,你最开始加个 ! , 例如:!src/xx.vue

lishaobos avatar Aug 03 '23 06:08 lishaobos

@lishaobos image 你有遇到这种情况嘛,我的插件是最新的,也重启重装过依赖

nigiwen avatar Aug 03 '23 09:08 nigiwen

这个 globs 里面可以写多个,你写了一个排除,可以再写几个命中,类似于下面

      globs: [
        'src/components/*.vue',
        '!src/components/ComponentA.vue',
      ],

lishaobos avatar Aug 03 '23 09:08 lishaobos

globs: [
    '!src/components/**/modules/*.vue',  //排除components下的所有modules文件夹里的组件
    'src/components/*.vue',
    'src/components/**/index.vue',
  ],

使用这种方式来排除

AprilLemon avatar Mar 09 '24 03:03 AprilLemon