RecipesChapter 12: Type Development Strategies

Testing Complex Types

Recipe 12.4 from The TypeScript Cookbook

export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE
  ? true
  : false;
export type ExpectValidArgs<
  FUNC extends (...args: any[]) => any,
  ARGS extends any[]
> = ARGS extends Parameters<FUNC> ? true : false;
Open in TypeScript Playground →