ts-type-forge
    Preparing search index...

    Type Alias ToMutableMap<T>

    ToMutableMap: T extends ReadonlyMap<infer K, infer V> ? Map<K, V> : never

    Converts a ReadonlyMap<K, V> type to its mutable counterpart Map<K, V>. Extracts the key and value types from the readonly map and creates a standard mutable Map.

    Type Parameters

    • T extends ReadonlyMap<any, any>

      A type that extends ReadonlyMap<any, any>.

    The corresponding mutable Map<K, V> type.

    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);
    };