javascript - Merge an interface and new key:value object for function parameter -
i have list of firebase objects search through , want various things object. problem facing fact firebase returns more complex object want have in interface. interface called placeonmap , looks this:
export interface location { address: string, latitude: number, longitude: number } the function want call should ideally this:
addplaceonmap(mappoint: { $key: string, placeonmap } ) { this.placeonmapids.push(mappoint.$key); this.newplaceonmap.next(mappoint.lat, mappoint.lng); this.uploadtofirebase(mappoint.$key, { name: mappoint.address, lat: mappoint.lat, lng: mappoint.lng }); } the point being, want combine $key receive firebase keys interface placeonmap has.
for completeness, stored object receive firebase looks this:
{ address: string, latitude: number, longitude: number, street: string, country: string, description: string } i think use typescript's union not clean want since expect receive this. know create new interface seems me overkill since use once.
if there no other way, resort any or using 2 parameters (probably former).
Comments
Post a Comment