import type {FromOption} from './fd-options.js'; // Options which can be fd-specific like `{verbose: {stdout: 'none', stderr: 'full'}}` export type FdGenericOption = OptionType | GenericOptionObject; type GenericOptionObject = Readonly>>; type GenericFromOption = FromOption | 'ipc'; // Retrieve fd-specific option's value export type FdSpecificOption< GenericOption extends FdGenericOption, FdNumber extends string, > = GenericOption extends GenericOptionObject ? FdSpecificObjectOption : GenericOption; type FdSpecificObjectOption< GenericOption extends GenericOptionObject, FdNumber extends string, > = keyof GenericOption extends GenericFromOption ? FdNumber extends '1' ? FdOptionValue>> : FdNumber extends '2' ? FdOptionValue>> : FdOptionValue : GenericOption; // Optional descriptor keys can be absent, so lower-priority keys can still apply. type FdOptionValue< GenericOption extends GenericOptionObject, Key extends string, Fallback = undefined, > = Key extends keyof GenericOption ? GenericOption[Key] | ({} extends Pick ? Fallback : never) : Fallback; export {};