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

unable to infer ComponentPropsOptions type from component #11853

Closed
guy-confetti opened this issue Sep 7, 2024 · 4 comments
Closed

unable to infer ComponentPropsOptions type from component #11853

guy-confetti opened this issue Sep 7, 2024 · 4 comments

Comments

@guy-confetti
Copy link

Vue version

3.5.3

Link to minimal reproduction

https://play.vuejs.org/#eNp9U01v2zAM/SuELm2BIDsUuxhJhnXrYQPWFWuOAgY3pjN1MqVRUtY0yH8vJTeumxa9yOLj44ce6Z367P10k1BVahZWbHyEgDF5sDWt51rFoNVCk+m84wg7aLA1hF+c2IQUJxC3HuHrSxT20LLr4EQSn2jStHIUIvzYPjPmx5lOd5oAPDsfKih3gNa54Q6lUgU3kQ2tJweQ8V8yjE0FkRM+wfun723Nr+IvnLNY05BA2qiTjRW0tQ14HP/wKv4qdbfIb9Qv8S8a6M9eztOzQyIWmykD8wVQsrZQNe3PslJFzkGU6yzHbLkQuZaA9xGpCcdizwy1yFCoE6hpW44FfOohqIBwgzwkH02hJ8yP62Waa8dE2YDZh3495CpGxM7bOmJxjAw1kY2RabdmPb0LjmStyrO1WkkuY5F/+mhkG7QalNWqttb9/16w0RQl5g+u/r6B34X7jGl1zRiQN6jV4Is1rzH27subKxFt5Oxck6yw33H+wuBsyj32tItEjbQ94pVuv5UfQjZxGS7zXMLhUbnRw0RFjd8iffaJEOfTj9NztX8E6OAk3g==

Steps to reproduce

minimal reproduction shows inferred props type returns the component's ExtractPropTypes

What is expected?

should be able to infer ComponentPropsOptions

What is actually happening?

until updating to v3.5, I've been using this snippet to infer public prop types from components

type ComponentProps<T> =
  T extends DefineComponent<infer Props, any, any>
    ? ExtractPublicPropTypes<Props>
    : never

but Props are now already extracted with ExtractPropTypes and I'm unable to infer ComponentPropsOptions to extract the public props

System Info

No response

Any additional comments?

I was unable to find the relevant commit, but I think this change was already introduced in 3.4

@sqal
Copy link
Contributor

sqal commented Sep 8, 2024

@guy-confetti
Copy link
Author

I've been using ExtractPublicPropTypes previously, but the inferred props from DefineComponent are already a result of ExtractPropTypes (internal props) which cannot be passed to ExtractPublicPropTypes

@jh-leong
Copy link
Member

jh-leong commented Sep 8, 2024

You can use this in v3.5 (Playground):

type ComponentProps<T> = T extends DefineComponent<
  ExtractPropTypes<infer Props>,
  any,
  any
>
  ? ExtractPublicPropTypes<Props>
  : never;

@jh-leong
Copy link
Member

jh-leong commented Sep 8, 2024

Since this isn't a bug within the framework but a change in internal behavior, I'll close this off. Let me know if you run into any other issues.

@jh-leong jh-leong closed this as completed Sep 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants