My approach to defining model classes involves using the following structure:
export class Company {
constructor(
public id?: number,
public name?: string,
public shortName?: string
) {}
}
I utilize the ?
symbol to prevent errors when assigning an empty company
object to a variable, such as in this example:
this.editDataItem = new Company();
Is there a way to eliminate the need for using ?
in the model declaration? Is this method appropriate for creating instances with empty properties? Are there any recommended best practices for handling this situation?