Typescript: how to create an object from interface

If you want to instantiate an object from an interface in typescript do this.
“new” object:

const address: Address = {} as Address;

Then can add values to properties.

Object initialization:

const modal: IModal = { 
  content: '', 
  form: '', 
  href: ''
};

 

Source: How can I create an object based on an interface file definition in TypeScript? – Stack Overflow

Leave a Reply