typescript create object of interface code example
Example 1: typescript create new object from interface
interface Foo {
bar: string;
qux: number;
}
// Creates object implementing interface:
const MyFoo = <Foo> {
bar: "Hello",
qux: 7
}
// Or:
const MyFoo: Foo = {
bar: "Hello",
qux: 7
}
Example 2: typescript new instance of interface
const modal = {} as IModal;
or
const modal: IModal = {
content: '',
form: '',
href: '',
$form: null,
$message: null,
$modal: null,
$submits: null
};