RecipesChapter 8: Helper Types

Allowing at Least One Property

Recipe 8.5 from The TypeScript Cookbook

function loadVideo(formats: Split<VideoFormatURLs>) {
  // tbd
}

loadVideo({});
//        ^
// Argument of type '{}' is not assignable to parameter
// of type 'Split<VideoFormatURLs>'

loadVideo({
  format480p: new URL("..."),
}); // all good
Open in TypeScript Playground →