Dev Helpers
← Back

Make all options optional

Make all options optional using TypeScript.

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({ limit: 10 } satisfies { [K in keyof Settings]?: Settings[K] });

Sample output

{ limit: 10 }