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

feat(menu): idea to introduce generics and better types for components #7114

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

J-Michalek
Copy link
Contributor

@J-Michalek J-Michalek commented Jan 18, 2025

Motivation

Better TS support which provides real type safety instead of just acting as any - mostly for safe usage of slotProps and emits payloads.

Explanation

In a codebase this large it is near impossible to convert everything into composition API with TS, but we can define "secondary" components that will handle the types in a way that Vue can understand perfectly including generic types.

In this PR I have prepared it for the Menu component which uses the MenuItem interface for the model prop.

This way of doing it should be a non-breaking change for all current usage as it would just infer the actual types of the items.

Caveats

Some prop types are very complicated, mostly the ones that extend large interfaces such as ButtonHTMLAttributes which the Vue compiler cannot handle when used inside of the defineProps macro. We would have to find a reasonable way around this. I go more into detail in this discussion: https://github.com/orgs/primefaces/discussions/3392

Copy link

vercel bot commented Jan 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Updated (UTC)
primevue ⬜️ Ignored (Inspect) Visit Preview Jan 18, 2025 4:11pm
primevue-v3 ⬜️ Ignored (Inspect) Visit Preview Jan 18, 2025 4:11pm

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 this pull request may close these issues.

1 participant