how to create object of interface in typescript 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: interface ts one valu
// use type instead interface
type StringOrNull = string | null;