It's recommended to export the vue/ rruntime -core/ -> PropOptions
What problem does this feature solve?
Wean 'props' from the main body
What does the proposed API look like?
import {defineComponent} from 'vue';
const componentProp: {[key: string]: PropOptions} = {};
export default defineComponent({
props: componentProp,
render() {
return <div>vue 3.0</div>
}
})
I know this is old and pretty closed, but trying to made something like a props
factory function to generate reusable props between components, I found quite dificult to return the right type.
My function is pretty simple
export function getIconDefaultProps() {
return {
width: {
type: [Number, String],
default: '1em'
},
height: {
type: [Number, String],
default: '1em'
},
color: {
type: String,
default: 'currentColor'
}
}
}
But trying to return a { [key: string]: Prop }
as @KaelWD says
export function getIconDefaultProps(): { [key: string]: Prop } { /* ... */ }
I got a Generic type 'Prop' requires between 1 and 2 type arguments.
error message, and I'm not pretty sure if create a type to solve this is what i need.
Then trying to return a ComponentPropsOptions
export function getIconDefaultProps(): ComponentPropsOptions { /* ... */ }
i got that the component where i wanna use the function doesn't resolve well the props type