I am creating a function called formatAddress which accepts an address object and property map object as input and outputs the mapped address.
function formatAddress(address, map): MappedAddressOutput {
...
}
type MappedAddressOutput = AnyObject[typeof AddressMap[keyof typeof AddressMap]];
interface Address {
addressLine1: string;
addressLine2: string;
city: string;
province: string;
postalCode: string;
}
const AddressMap = {
addressLine1: "address1",
addressLine2: "address2",
city: "city",
province: "province",
postalCode: "postalCode"
};
type IndexSignature = string | number | symbol;
type AnyObject = { [key: IndexSignature]: any };
If I wish to transform the MappedAddressOutput as the code below:
type MappedAddressOutput = ObjectValueAsKey<AddressMap>
How can I implement ObjectValueAsKey type?
formatAddressfunction. Could you be more precise pls