import type { Simplify, ValueOf } from 'type-fest'; export type DerivedPropertiesOnlyOf = Simplify<{ [K in Choices as `${Property}${Capitalize}`]: boolean; }>; /* * @example * ```ts * DerivedPropertiesOf<'clientFramework', 'angular' | 'no'> = * { clientFrameworkAngular: boolean; clientFrameworkNo: boolean; clientFramework: 'angular' | 'no'; clientFrameworkAny: boolean; } * ``` */ export type DerivedPropertiesOf = Simplify< { [K in Choices as `${Property}${Capitalize}`]: boolean; } & Record & Record<`${Property}Any`, boolean> >; /* * @example * ```ts * DerivedPropertiesWithInferenceOf<'clientFramework', 'angular', 'angular', 'no'> = * { clientFrameworkAngular: true; clientFrameworkNo: false; clientFramework: 'angular'; clientFrameworkAny: true; } * ``` */ type DerivedPropertiesWithInferenceOf

= Simplify< { [K in C as `${P}${Capitalize}`]: K extends V ? true : false; } & Record & Record<`${P}Any`, V extends 'no' ? false : true> >; /** * ```ts * type ExplodedConfigChoices = ExplodeDerivedPropertiesWithInference<['angular', 'no'], 'clientFramework'>; * type ExplodedConfigChoices = * | { clientFrameworkAngular: true; clientFrameworkNo: false; clientFramework: 'angular'; clientFrameworkAny: true; } * | { clientFrameworkAngular: false; clientFrameworkNo: true; clientFramework: 'no'; clientFrameworkAny: true; } * ``` */ export type DerivedPropertiesWithInferenceUnion = ValueOf<{ [Index in Exclude]: Choices[Index] extends infer Choice ? Choice extends string ? DerivedPropertiesWithInferenceOf : never : never; }>;