Skip to content

Commit

Permalink
Reduce type complexity (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored May 9, 2024
1 parent f768c1a commit cf70951
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions types/subprocess/all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@ import type {IgnoresSubprocessOutput} from '../return/ignore.js';
import type {Options} from '../arguments/options.js';

// `subprocess.all`
export type SubprocessAll<OptionsType extends Options = Options> = AllStream<OptionsType['all'], OptionsType>;
export type SubprocessAll<OptionsType extends Options = Options> = AllStream<AllIgnored<OptionsType['all'], OptionsType>>;

type AllStream<
type AllStream<IsIgnored> = IsIgnored extends true ? undefined : Readable;

type AllIgnored<
AllOption extends Options['all'] = Options['all'],
OptionsType extends Options = Options,
> = AllOption extends true
? AllIfStdout<IgnoresSubprocessOutput<'1', OptionsType>, OptionsType>
: undefined;

type AllIfStdout<
StdoutResultIgnored extends boolean,
OptionsType extends Options = Options,
> = StdoutResultIgnored extends true
? AllIfStderr<IgnoresSubprocessOutput<'2', OptionsType>>
: Readable;

type AllIfStderr<StderrResultIgnored extends boolean> = StderrResultIgnored extends true
? undefined
: Readable;
? IgnoresSubprocessOutput<'1', OptionsType> extends true
? IgnoresSubprocessOutput<'2', OptionsType>
: false
: true;

0 comments on commit cf70951

Please sign in to comment.