Open this example in the interactive library
Source code
type Settings = { theme: string; limit: number; debug: boolean };
const settings: Settings = { theme: "dark", limit: 4, debug: false };
console.log(
((v: { -readonly [K in keyof Readonly<Settings>]: Settings[K] }) => {
v.limit++;
return v.limit;
})({ ...settings }),
);
Sample output
5
