Imagine having an interface like the one below with 10 or more properties:
export interface EmployeeFilter {
name: string;
gender: string;
age: number;
from: Date;
to: Date;
module: string;
position: string;
phone: string;
email: string;
country: string;
}
Is there a way to automatically initialize an object with the properties defined in EmployeeFilter
without explicitly setting them?
Currently, I have to manually set the properties like this:
const searchby: EmployeeFilter = {
name: '',
gender: '',
age: 28,
from: null,
to: null,
module: '',
position: '',
phone: '',
email: '',
country: ''
}
I am searching for a method that would automatically initialize all the properties of EmployeeFilter
by setting them to null
. I've experimented with different approaches such as:
const searchby: EmployeeFilter = new class implements EmployeeFilter{}();
However, when I do console.log(searchby);
, all I see is an empty object literal {}
.