There's a "calendar" component in my project that needs to consume data from the caller and display all the days in a month. If there is data for a particular day, I want to show another component inside it. The problem is that the calendar component doesn't know what type of component it should use for each day slot.
I initially thought I could utilize a Vue3 generic component like this:
- The data would be passed as a prop with a type of
Record<string, T[]>
(where the key follows the formatY-m-d
) - The desired component would be passed as a prop with a type of
DefineComponent<T>
// Your code example here
Despite working on the browser, the TypeScript compiler throws errors:
Your compiler error messages here
Play around with this Vue playground that showcases how the component is used
Can anyone guide me on the correct way to define types in order for the compiler to validate data against props for the component?