typescript interface optional with default value code example
Example 1: ts interface optional parameter
interface Person {
name: string;
age: number;
phone?: string;
}
let p: Person = {name: "Ashlee", age: 29};
console.log(p);
Example 2: typescript interface default value
// Use optionalproperties (here b and c)
interface IX {
a: string,
b?: any,
c?: AnotherType
}
let x: IX = {
a: 'abc'
}