Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 793 Bytes

File metadata and controls

30 lines (21 loc) · 793 Bytes

Home > types-kit > SetReadonly

SetReadonly type

Make some properties in T readonly (add readonly decorator).

Signature:

export type SetReadonly<T, K extends Keys<T>> = Simplify<
  StrictOmit<T, K> & Readonly<Pick<T, K>>
>

References: Keys, Simplify, StrictOmit

Example

interface Props {
      a: number;
      b: number;
      c: number;
    };
    // Expect: { readonly a: number; readonly b:   number; c: number; }
    type NewProps = SetReadonly<Props, 'a' | 'b'>;