RecipesChapter 12: Type Development Strategies

Writing Low Maintenance Types

Recipe 12.1 from The TypeScript Cookbook

const defaultOptions = {
  from: "./src",
  to: "./dest",
  overwrite: true,
};

function copy(options: Partial<typeof defaultOptions>) {
  // Let's merge default options and options
  const allOptions = { ...defaultOptions, ...options};

  // todo: Implementation of the rest
}
Open in TypeScript Playground →