In my development work with React, I often utilize a props object structured like this:
const props: { id: number, name?: string} = { id: 1 }; // 'name' property not defined
const { id, name } = props; // the 'name' constant is now forever undefined, even when using defaultProps in React and receiving warnings from Typescript about potential undefined values
Is there a method to incorporate nullish coalescing while destructuring the object?
Note that I am unable to use the following code snippet (due to an ESlint rule enforced by the team):
const name = props.name ?? 'placeholder name';