Original Answer
The issue occurs when you try to instantiate the class without passing arguments, as you did not specify arguments will be optional.
Make arguments optional like this
export class User {
...
constructor(id?: number, etabName?: string, ) {
this.id = id || 0; //Specify default value
this.etabName = etabName || ''; //Specify default value
}
...
}
then you can instantiate class without arguments
const user = new User();//works
Update
You can write it even better with this syntax below, Typescript will take care of creating properties and assigning default values to it.
class User {
constructor(private id: number = 0, private etabName: string = '') {
}
...setters and getters omitted for readability
}
The above typescript will be converted to below javascript
class User {
constructor(id = 0, etabName = '') {
this.id = id;
this.etabName = etabName;
}
...setters and getters omitted for readability
}