I am converting my code from Javascript to Typescript my code below works in Javascript, but it has an error in Typescript
here is the code
const jsonData = {
query: "keywords in here",
page: {size: 10, current: 1},
options: {
all: [
{ datetimestart: {from: currentDateTimeInISOString}},
{ price: {from: 0, to: (freeEventsOnly ? 0.1 : 99999999999) }},
],
},
};
if (meetSomeCondition) {
jsonData.options.all.push({ city: domicile }); // <--- try to append another object to array
}
as you can see, I have an object called jsonData
, and this object has a property called options
which is an object that has property called all
that is an array of multiple object
and then try to append another object to array, but I have this error
it seems I push an object that has different data type? how to solve this?
question from:https://stackoverflow.com/questions/66062735/can-i-have-a-property-in-an-object-that-is-an-array-of-multiple-object-in-typesc