RestrictiveReadonlyRecord

Packages > @fluidframework/tree > RestrictiveReadonlyRecord

Alternative to the built in Record type which does not permit unexpected members, and is readonly.

This API is deprecated and will be removed in a future release.

Use a more robust / specific type instead. This type never worked as intended.

Signature

export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
    readonly [P in symbol | string]: P extends K ? T : never;
};

Type Parameters

Parameter Constraint Description
K symbol | string
T

Remarks

This does not work correctly when K is more specific than string or symbol. For example {a: 5} is not assignable to RestrictiveReadonlyRecord<"a",: number>