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

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

Closed
JackieCheung opened this issue Jun 14, 2022 · 9 comments · Fixed by #773
Closed

Comments

@JackieCheung
Copy link

JackieCheung commented Jun 14, 2022

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

--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 JackieCheung changed the title 如何匹配指定名称的组件作为真正需要自动引入的组件 如何配置指定名称的组件才在components.d.ts文件中生成类型声明 Jun 14, 2022
@azaleta
Copy link
Contributor

azaleta commented Jun 29, 2022

@JackieCheung

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

@kingyue737
Copy link

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.

@paul-xia
Copy link

I also want this feature too.

@cx741041875
Copy link

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

@nigiwen
Copy link

nigiwen commented Aug 3, 2023

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

@lishaobos
Copy link
Contributor

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

@nigiwen
Copy link

nigiwen commented Aug 3, 2023

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

@lishaobos
Copy link
Contributor

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

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

@AprilLemon
Copy link

AprilLemon commented Mar 9, 2024

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

使用这种方式来排除

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

Successfully merging a pull request may close this issue.

8 participants