I have defined a const called MODAL_OPTION_PROP
to set common props for a modal:
export const MODAL_OPTION_PROP = {
modalOption: {
type: Object as PropType<ModalOptionParams>,
default: DEFAULT_MODAL_OPTION,
},
};
I am trying to use it in a modal component with defineProps
const props = defineProps(
Object.assign({}, MODAL_OPTION_PROP, {
currentItem: {
type: Object as PropType<Item>,
required: true,
},
})
);
const editingItem = ref<Item>(props.currentItem);
However, I am getting a not assignable
warning on props.currentItem
:
(property) currentItem?: Item | undefined
Argument of type 'Item | undefined' is not assignable to parameter of type 'Item'.
Type 'undefined' is not assignable to type 'Item'.ts(2345)
It seems like currentItem
is becoming optional. Is there a way to prevent this unexpected behavior?