I'm trying to assign a object to initialState variable, the selectedActivity type is Activity | undefined and after Nullish Coalescing operator (??) the emptyActivity is of type Activity.
but when this line execute, it throws an error that says: Module parse failed: Unexpected token You may need an appropriate loader to handle this file type.
Code:
interface Props {
selectedActivity: Activity | undefined
closeForm: () => void
}
export default function ActivityForm({ selectedActivity, closeForm }: Props) {
const emptyActivity: Activity = {
id: '',
title: '',
date: '',
description: '',
category: '',
city: '',
venue: '',
}
const initialState = selectedActivity ?? emptyActivity;
and this is Activity interface:
export interface Activity {
id: string
title: string
date: string
description: string
category: string
city: string
venue: string
}
I'm coding a react project and I want to solve the assignment error.