Within my interface, there is a property named data
which contains an array. The structure looks like this:
type Data = { prop1: string; prop2: string }[];
interface MyInterface {
prop1: string;
data: Data;
}
Now, I have an RxJS stream where the type is MyInterface
.
I want to modify the data property slightly by adding a new value.
type DataExtended = Data & {
newValue: string
}
This new type is added to an extended interface.
interface MyInterfaceExtended extends MyInterface {
data: DataExtended
}
In the controller, I invoke a service that expects an HTTP result of type MyInterface
. However, I need to alter the data structure as follows:
var myData$ = Observable<MyInterfaceExtended>;
constructor(private myService:myservice){
this.myData$ = this.myService.get().pipe((map(value)) => {
foreach(value.data, (data) =>{
data.newValue = 'new';
})
return value
})
}
Despite this setup, I am encountering an error stating:
'newValue' does not exist on type {etc}
What could be causing this issue?