I have the following interface in TypeScript:
interface IX {
a: string,
b: any,
c: AnotherType
}
I declare a variable of that t
You can't set default values in an interface, but you can accomplish what you want to do by using Optional Properties (compare paragraph #3):
https://www.typescriptlang.org/docs/handbook/interfaces.html
Simply change the interface to:
interface IX {
a: string,
b?: any,
c?: AnotherType
}
You can then do:
let x: IX = {
a: 'abc'
}
And use your init function to assign default values to x.b and x.c if those properies are not set.