Here is the layout of my interface
interface IPlacesResult {
summary: {
queryTime: number;
// ...
};
results: {
id: string;
// ...
address: {
streetNumber: number;
// ...
};
}[];
}
To populate this interface, I use
this.http.get<IPlacesResult>(environment.azure.locationService.url ...
and then proceed to filter for unique values
.pipe(
map(result => {
const resultsMap = new Map<string, IPlacesResult['results']>();
result.results.forEach(r => {
const rKey = PlaceSearchResult.toAddressFull(r.address.streetNumber, r.address.streetName,
r.address.municipalitySubdivision, r.address.countrySubdivision, r.address.postalCode);
if (!resultsMap.has(rKey)) {
resultsMap.set(rKey, r); // This line throws an error
}
...
The issue arises in the specified line, displaying the following message
[ts]
Argument of type
'{ id: string; type: string; score: number; address: { streetNumber: number; streetName: string; m...'
is not assignable to parameter of type
'{ id: string; type: string; score: number; address: { streetNumber: number; streetName: string; m...'.
Property 'includes' is missing in type
'{ id: string; type: string; score: number; address: { streetNumber: number; streetName: string; m...'.
Attempts using the as
operator have also failed with the same error message.
How should I go about successfully filtering the items?