Enforce strict typing and consistent handling of component props and events to ensure type safety, runtime validation, and maintainable component interfaces. Key guidelines:
Enforce strict typing and consistent handling of component props and events to ensure type safety, runtime validation, and maintainable component interfaces. Key guidelines:
export default {
props: {
value: {
type: Number,
required: true,
validator: (val) => val >= 0
},
options: {
type: Array,
default: () => [] // Use function for object/array defaults
}
}
}
export default {
emits: {
'update:modelValue': (value: number) => value >= 0,
'change': (value: number, oldValue: number) => true
}
}
This ensures components are type-safe, self-documenting, and maintainable while preventing common runtime errors.
Enter the URL of a public GitHub repository