Consider the following interfaces :
interface MyType1 {
field1: string;
options: {
basicOption1: string;
basicOption2: string;
};
}
interface MoreOptions {
moreOptions1: string;
moreOptions2: string;
}
I extend the field options of interface MyType1 :
interface MyType2 extends MyType1{
options: {
basicOption1: string; // How to remove it, yet declared in MyType1
basicOption2: string; // How to remove it, yet declared in MyType1
moreOptions1: string;
moreOptions2: string;
};
}
If I omit lines : basicOptions1:string;and basicOptions2:string;, compiler complains. So, I add them. But, is it possible to remove them and only keep lines : moreOptions1:string; and moreOptions2:string; for the additional options.
Following, how could I assign an object of type Mytype2 from two objects of type MyType1 and MoreOptions ?
For example (Rq : I test other things but also unsuccessful) :
let myobj1: MyType1 = { field1:"field1", options:{ basicOption1:"basicOption1", basicOption2:"basicOption2" } };
let moreOptions: MoreOptions = { moreOptions1: "moreOptions1", moreOptions2: "moreOptions2" }
let myobj2: MyType2 = { ...myobj1, options: {...moreOptions} };