In Vue 3, I'm creating a function that will accept an instance of a component and a property to be passed. I'm also using TypeScript and wondering if I can enter these parameters. For example, the function would look like:
const example = (component, props) => { // };
So my question is:
You can use the many features provided by typescript and the
Component
types in vue to achieve proper typing, create a generic type that extendsComponent
and then infer the component options/props usinginfer
, use Partial to make them optional:Note: This also infers properties and component instance utilities