A type that extends ReadonlyMap<any, any>.
type ReadOnlyUserMap = ReadonlyMap<string, User>;
type MutableUserMap = ToMutableMap<ReadOnlyUserMap>; // Map<string, User>
// Useful when you need to convert readonly collections to mutable ones
const convertToMutable = (readonlyMap: ReadonlyMap<string, number>): Map<string, number> => {
return new Map(readonlyMap);
};
Converts a
ReadonlyMap<K, V>type to its mutable counterpartMap<K, V>. Extracts the key and value types from the readonly map and creates a standard mutable Map.