[Feature Request] TypeScript Infinite Type Instantiation with ComponentProps<typeof VSelect>
#21.430 aperta il 18 mag 2025
Metriche repository
- Star
- (40.995 stelle)
- Metriche merge PR
- (Merge medio 59g 10h) (8 PR mergiate in 30 g)
Descrizione
Problem to solve
When trying to extract props types from Vuetify components using a generic helper like:
type ComponentProps<C extends Component> = C extends new (...args: any) => any
? Omit<InstanceType<C>["$props"], keyof VNodeProps | keyof AllowedComponentProps>
: never;
export type TToolBar = ComponentProps<typeof VToolbar>; // Works fine
export type TMultiSelect = ComponentProps<typeof VSelect>; // Causes "Type instantiation is excessively deep and possibly infinite" error
The problem arises because VSelect’s $props type is extremely complex and deeply nested, which causes TypeScript to hit its recursion or complexity limit and throw the “excessively deep and possibly infinite” instantiation error.
This makes it difficult to create reusable and type-safe utilities around Vuetify components, especially for those like VSelect with very rich and conditional prop types.
Proposed solution
To avoid forcing users into complex workarounds, such as manually picking subsets of props or using partial types, it would be beneficial if Vuetify’s type definitions could:
- Provide a more flattened or simplified prop type export for components with complex props (e.g. VSelect), suitable for type extraction without triggering TS recursion limits.
- Alternatively, offer an explicit type alias or utility type that extracts a stable, pre-processed prop type for each component.
- This could be implemented by adjusting the internal prop typing to avoid deeply recursive conditional types or by splitting complex union types into simpler segments.
Such improvements would enhance the developer experience by enabling seamless, type-safe usage of Vuetify components in TypeScript projects, without hitting compiler limits.