Open phijma-leukeleu opened 6 months ago
I've used this approach:
import type { Component } from 'vue';
import type { DynamicDialogOptions } from 'primevue/dynamicdialogoptions';
/**
* vue-component-type-helpers
* Copy from https://github.com/vuejs/language-tools/tree/master/packages/component-type-helpers
*/
export type ComponentProps<T> = T extends new () => {
$props: infer P;
} ? NonNullable<P> : T extends (props: infer P, ...args: any) => any ? P : unknown;
export interface DialogOptions<T extends Component> extends DynamicDialogOptions {
data?: ComponentProps<T>;
}
That's too much boilerplate, we definitely need easier way to define data
type.
For now I'm just using the render function..
const dialog = useDialog()
dialog.open(h(SomeComponent, { someProp }))
Currently you can pass
data
when you want to open a dialog:Is it possible to make this work with typescript? In this case:
SomeComponent
needssomeProp
, so auto completion would be preferred.