Skip to content

Commit

Permalink
Fix complexity type error (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 9, 2024
1 parent 3bdab60 commit fee011d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions types/transform/object-mode.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {StdioSingleOption, StdioOptionCommon} from '../stdio/type.js';
import type {FdStdioOption} from '../stdio/option.js';
import type {CommonOptions} from '../arguments/options.js';
import type {GeneratorTransformFull, DuplexTransform, WebTransform} from './normalize.js';
import type {DuplexTransform} from './normalize.js';

// Whether a file descriptor is in object mode
// I.e. whether `result.stdout|stderr|stdio|all` is an array of `unknown` due to `objectMode: true`
Expand All @@ -15,14 +15,10 @@ type IsObjectStdioOption<StdioOptionType extends StdioOptionCommon> = IsObjectSt
: StdioOptionType
>;

type IsObjectStdioSingleOption<StdioSingleOptionType extends StdioSingleOption> = StdioSingleOptionType extends GeneratorTransformFull<boolean> | WebTransform
type IsObjectStdioSingleOption<StdioSingleOptionType extends StdioSingleOption> = StdioSingleOptionType extends {objectMode?: boolean}
? BooleanObjectMode<StdioSingleOptionType['objectMode']>
: StdioSingleOptionType extends DuplexTransform
? DuplexObjectMode<StdioSingleOptionType>
? StdioSingleOptionType['transform']['readableObjectMode']
: false;

type BooleanObjectMode<ObjectModeOption extends boolean | undefined> = ObjectModeOption extends true ? true : false;

type DuplexObjectMode<OutputOption extends DuplexTransform> = OutputOption['objectMode'] extends boolean
? OutputOption['objectMode']
: OutputOption['transform']['readableObjectMode'];

0 comments on commit fee011d

Please sign in to comment.