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

Declaration files d.ts not generated for generic component #4569

Closed
zaalbarxx opened this issue Jul 9, 2024 · 2 comments
Closed

Declaration files d.ts not generated for generic component #4569

zaalbarxx opened this issue Jul 9, 2024 · 2 comments
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@zaalbarxx
Copy link

Vue - Official extension or vue-tsc version

2.0.26

VSCode version

Vue version

3.4.21

TypeScript version

5.4 and 5.5.3

System Info

No response

Steps to reproduce

  1. Go to this example repo https://stackblitz.com/edit/vite-ungnsb?file=package.json,src%2Fcomponents%2FTableRow.vue,src%2Ftypes.ts,tsconfig.dist.json,src%2Fcomponents%2FTableRowCell.vue,src%2Fcomponents%2FEmptyTableRow.vue
  2. in terminal run vue-tsc -p tsconfig.dist.json
  3. Check dist folder

What is expected?

I would expect that dist folder contains components/EmptyTableRow.vue.d.ts and components/TableRow.vue.d.ts files.

What is actually happening?

For some reason the declaration files are not emitted for these components. But interesingly the AppTableRowCell is also a generic component which look quite similar to AppTableRow and the declaration file is emitted correctly for it. When I either remove defineProps() from EmptyTableRow.vue or remove the generic="..." the declaration file is then emitted. It is quite strange, because no error is being emitted from the command itself, it's just that the files are not there.

Link to minimal reproduction

https://stackblitz.com/edit/vite-ungnsb?file=package.json,src%2Fcomponents%2FTableRow.vue,src%2Ftypes.ts,tsconfig.dist.json,src%2Fcomponents%2FTableRowCell.vue,src%2Fcomponents%2FEmptyTableRow.vue

Any additional comments?

No response

@zaalbarxx
Copy link
Author

Hmmmm, after some checking, by downgrading to 1.8.27 and TS to 5.4.5 the files are emitted correctly. Seems like there is some regression here with 2.x ?

@redwarff
Copy link

redwarff commented Jul 15, 2024

I have bumped into similar issue. I think the problem is that there is this error: Default export of the module has or is using private name 'Props' which is not actually reported anywhere. It was only reported in the console in my project when I tried generating .d.ts files using vite-plugin-dts.

I don't know what is going on here or why it works in older versions, but as a workaround for now you can define your props in generic components as type instead of an interface, mentioned here: #3266

type Props = {
  ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

3 participants