Home > types-kit > SetReadonly
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
interface Props {
a: number;
b: number;
c: number;
};
// Expect: { readonly a: number; readonly b: number; c: number; }
type NewProps = SetReadonly<Props, 'a' | 'b'>;