Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by GitHub · parent 4b0edb3 · Browse files · 14 files·+153 added−32 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
14 files+153 added−32 removed
- tests:+42 added−0 removed
- other:+111 added−32 removed
Provenance
- Commit
9fbf5ba- Tree
4c4b054- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
4b0edb3
14 files changed+153 added−32 removed
modified:docs/api.md+2 added-2 removed
914 unmodified lines915 916 ### options.stdio917 918 _TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\919-_Type:_ `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream} | {value: 'pipe'; input?: boolean}>` (or a tuple of those types)\919+_Type:_ `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream} | {value: 'pipe' | 'inherit' | number | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}; input?: boolean}>` (or a tuple of those types)\920 _Default:_ `pipe`921 922 Like the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options but for all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.923 924 A single string can be used [as a shortcut](output.md#shortcut).925 926-The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr). Passing `'pipe'` to an additional file descriptor defaults it to output. To use it for [input](input.md#additional-file-descriptors) instead, pass `{value: 'pipe', input: true}`.926+The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr). Some values have an ambiguous direction on an additional file descriptor (like `'pipe'`, `'inherit'`, a file or a transform), so they default to output. To use one for [input](input.md#additional-file-descriptors) instead, wrap it as `{value, input: true}`.927 928 More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).929 930 ### options.all377 unmodified linesmodified:docs/input.md+1 added-1 removed
133 unmodified linesExpand all13413513613713813813914014114213 unmodified lines133 unmodified linesExpand all stdio: ['pipe', 'pipe', 'pipe', new Uint8Array([/* ... */])],})`npm run build`;```
When passing `'pipe'` to an additional file descriptor, Execa cannot tell whether it is meant for input or output, so it defaults to output. To use it for input instead, such as when [streaming](streams.md#different-file-descriptor) to it, pass `{value: 'pipe', input: true}`.Some values have an ambiguous direction on an additional file descriptor: Execa cannot tell whether they are meant for input or output, so they default to output. This applies to `'pipe'`, `'inherit'`, [files](output.md#file-output) and [transforms](transform.md). To use one for input instead, such as when [streaming](streams.md#different-file-descriptor) to it, wrap it as `{value, input: true}`.
```jsimport {pipeline} from 'node:stream/promises';
13 unmodified linesmodified:lib/stdio/direction.js+12 added-1 removed
20 unmodified lines21 };22 23 // `direction` is set when the user explicitly requests it, e.g. `{value: 'pipe', input: true}`.24 // It takes precedence over guessing, but not over the fixed direction of `stdin`/`stdout`/`stderr`.25-const getStdioItemDirection = ({type, value, direction}, fdNumber) => KNOWN_DIRECTIONS[fdNumber] ?? direction ?? guessStreamDirection[type](value);25+const getStdioItemDirection = (stdioItem, fdNumber) => KNOWN_DIRECTIONS[fdNumber] ?? getRequestedDirection(stdioItem);26 27+// The explicitly requested `direction` must not contradict a value that is intrinsically the other direction.28+// For example, `{value: writableStream, input: true}` is invalid since a writable value can only be an output.29+const getRequestedDirection = ({type, value, direction, optionName}) => {30+ const guessedDirection = guessStreamDirection[type](value);31+ if (direction === 'input' && guessedDirection === 'output') {32+ throw new TypeError(`The \`${optionName}\` option is invalid: \`input: true\` cannot be used with a writable value, which is always an output.`);33+ }34+35+ return direction ?? guessedDirection;36+};37+38 // `stdin`/`stdout`/`stderr` have a known direction39 const KNOWN_DIRECTIONS = ['input', 'output', 'output'];40 41 const anyDirection = () => undefined;48 unmodified linesmodified:lib/stdio/handle.js+6 added-6 removed
3 unmodified lines4 import {5 getStdioItemType,6 isRegularUrl,7 isUnknownStdioString,8- isPipeInputObject,8+ isStdioValueObject,9 checkBooleanOption,10 FILE_TYPES,11 } from './type.js';12 import {getStreamDirection} from './direction.js';71 unmodified lines84 && stdioItems[0].type === 'native'85 && stdioItems[0].value === 'inherit';86 87 const initializeStdioItem = (value, optionName) => {88- if (isPipeInputObject(value)) {89- return initializePipeInputItem(value, optionName);88+ if (isStdioValueObject(value)) {89+ return initializeStdioValueObject(value, optionName);90 }91 92 return {93 type: getStdioItemType(value, optionName),1 unmodified line95 optionName,96 };97 };98 99-// The `{value: 'pipe', input: true}` object form is a native pipe, plus an explicit input direction.100-const initializePipeInputItem = ({value, input}, optionName) => {99+// The `{value, input}` object form wraps any stdio value with an explicit direction.100+const initializeStdioValueObject = ({value, input}, optionName) => {101 checkBooleanOption(input, `${optionName}.input`);102 103 return {104- type: 'native',104+ type: getStdioItemType(value, optionName),105 value,106 direction: input ? 'input' : undefined,107 optionName,108 };135 unmodified linesmodified:lib/stdio/stdio-option.js+19 added-3 removed
1 import {STANDARD_STREAMS_ALIASES} from '../utils/standard-stream.js';2 import {normalizeIpcStdioArray} from '../ipc/array.js';3 import {isFullVerbose} from '../verbose/values.js';4-import {isPipeInputObject} from './type.js';4+import {isStdioValueObject} from './type.js';5 6 // Add support for `stdin`/`stdout`/`stderr` as an alias for `stdio`.7 // Also normalize the `stdio` option.8 export const normalizeStdioOption = ({stdio, ipc, buffer, ...options}, verboseInfo, isSync) => {5 unmodified lines14 };15 16 // The `stdio: 'ipc'` value (raw `child_process` syntax) was replaced by the `ipc: true` option17 const validateIpcStdioOption = stdioArray => {18- if (stdioArray.some(stdioOption => Array.isArray(stdioOption) ? stdioOption.includes('ipc') : stdioOption === 'ipc')) {18+ if (stdioArray.some(stdioOption => hasIpcStdioOption(stdioOption))) {19 throw new Error('The `ipc: true` option must be used instead of `stdio: \'ipc\'`.');20 }21 };22 23+const hasIpcStdioOption = stdioOption => {24+ if (Array.isArray(stdioOption)) {25+ return stdioOption.some(item => hasIpcStdioItem(item));26+ }27+28+ return hasIpcStdioItem(stdioOption);29+};30+31+const hasIpcStdioItem = stdioOption => {32+ if (isStdioValueObject(stdioOption)) {33+ return stdioOption.value === 'ipc';34+ }35+36+ return stdioOption === 'ipc';37+};38+39 const getStdioArray = (stdio, options) => {40 if (stdio === undefined) {41 return STANDARD_STREAMS_ALIASES.map(alias => options[alias]);42 }43 unmodified lines86 87 const isOutputPipe = (stdioOption, fdNumber) => stdioOption === 'pipe'88 || isOutputPipeObject(stdioOption, fdNumber);89 74-const isOutputPipeObject = (stdioOption, fdNumber) => isPipeInputObject(stdioOption)90+const isOutputPipeObject = (stdioOption, fdNumber) => isStdioValueObject(stdioOption)91 && stdioOption.value === 'pipe'92 && (stdioOption.input === undefined || stdioOption.input === false || isFixedOutputPipe(fdNumber, stdioOption.input));93 94 // On `stdout`/`stderr`, the direction is always output, so `input: true` is ignored and the pipe stays output.1 unmodified linemodified:lib/stdio/type.js+6 added-7 removed
128 unmodified lines129 && isFilePathString(value.file);130 const FILE_PATH_KEYS = new Set(['file', 'append']);131 export const isFilePathString = file => typeof file === 'string';132 133-// The `{value: 'pipe', input: true}` object form marks an additional file descriptor as input instead of output.134-// This is only needed for `'pipe'`/`'overlapped'` on fd3+, whose direction is otherwise ambiguous and defaults to output.135-export const isPipeInputObject = value => isPlainObj(value)133+// The `{value, input}` object form marks an additional file descriptor's direction explicitly.134+// This is needed for direction-ambiguous values (like `'pipe'`, `'inherit'`, a file or a transform) on fd3+, which otherwise default to output.135+export const isStdioValueObject = value => isPlainObj(value)136 && Object.keys(value).length > 0137- && Object.keys(value).every(key => PIPE_INPUT_KEYS.has(key))138- && NATIVE_PIPE_VALUES.has(value.value);139-const PIPE_INPUT_KEYS = new Set(['value', 'input']);140-const NATIVE_PIPE_VALUES = new Set(['pipe', 'overlapped']);137+ && Object.keys(value).every(key => STDIO_VALUE_KEYS.has(key))138+ && 'value' in value;139+const STDIO_VALUE_KEYS = new Set(['value', 'input']);140 141 export const isUnknownStdioString = (type, value) => type === 'native'142 && typeof value === 'string'143 && !KNOWN_STDIO_STRINGS.has(value);38 unmodified linesmodified:test/stdio/direction.js+30 added
58 unmodified lines59 60 test('stdio[*] { value: "pipe", input: true } sets the direction to input', testDirectionInputPipe, {value: 'pipe', input: true});61 test('stdio[*] { value: "overlapped", input: true } sets the direction to input', testDirectionInputPipe, {value: 'overlapped', input: true});62 63+const uppercaseGenerator = function * (line) {64+ yield line.toUpperCase();65+};66+67+test('stdio[*] { value: generator, input: true } sets the direction to input', async t => {68+ const subprocess = execa('stdin-fd.js', ['3'], getStdio(3, {value: uppercaseGenerator, input: true}));69+ subprocess.stdio[3].end(foobarString);70+ const {stdout} = await subprocess;71+ t.is(stdout, foobarString.toUpperCase());72+});73+74+test('stdio[*] { value: {file}, input: true } sets the direction to input', async t => {75+ const filePath = tempfile();76+ await writeFile(filePath, foobarString);77+ const {stdout} = await execa('stdin-fd.js', ['3'], getStdio(3, {value: {file: filePath}, input: true}));78+ t.is(stdout, foobarString);79+ await rm(filePath);80+});81+82+const testInputFixedDirection = (t, stdioOption, execaMethod) => {83+ t.throws(() => {84+ execaMethod('empty.js', getStdio(3, {value: stdioOption, input: true}));85+ }, {message: /cannot be used with a writable value/});86+};87+88+test('stdio[*] { value: WritableStream, input: true } is invalid', testInputFixedDirection, new WritableStream(), execa);89+test('stdio[*] { value: WritableStream, input: true } is invalid - sync', testInputFixedDirection, new WritableStream(), execaSync);90+test('stdio[*] { value: process.stdout, input: true } is invalid', testInputFixedDirection, process.stdout, execa);91+test('stdio[*] { value: process.stdout, input: true } is invalid - sync', testInputFixedDirection, process.stdout, execaSync);92+93 test('stdio[*] { value: "pipe", input: true } cannot be used in sync mode', t => {94 t.throws(() => {95 execaSync('empty.js', getStdio(3, {value: 'pipe', input: true}));96 }, {message: /can be an input pipe with synchronous methods/});41 unmodified linesmodified:test/stdio/handle-invalid.js+4 added
64 unmodified lines65 test('stdio cannot be "ipc"', testIpcStdioOption, 'stdio', 'ipc', execa);66 test('stdio cannot be "ipc" - sync', testIpcStdioOption, 'stdio', 'ipc', execaSync);67 test('stdio[*] cannot be ["ipc"]', testIpcStdioOption, 3, ['ipc'], execa);68 test('stdio[*] cannot be ["ipc"] - sync', testIpcStdioOption, 3, ['ipc'], execaSync);69+test('stdio[*] cannot be {value: "ipc"}', testIpcStdioOption, 3, {value: 'ipc'}, execa);70+test('stdio[*] cannot be {value: "ipc"} - sync', testIpcStdioOption, 3, {value: 'ipc'}, execaSync);71 test('Cannot pass "ipc" and another value to stdio[*]', testIpcStdioOption, 3, ['pipe', 'ipc'], execa);72 test('Cannot pass "ipc" and another value to stdio[*] - sync', testIpcStdioOption, 3, ['pipe', 'ipc'], execaSync);73+test('Cannot pass {value: "ipc"} and another value to stdio[*]', testIpcStdioOption, 3, ['pipe', {value: 'ipc'}], execa);74+test('Cannot pass {value: "ipc"} and another value to stdio[*] - sync', testIpcStdioOption, 3, ['pipe', {value: 'ipc'}], execaSync);modified:test/stdio/iterable.js+8 added
46 unmodified lines47 const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));48 t.is(stdout, 'foobar');49 };50 51+const testIpcDataIterable = async (t, fdNumber, execaMethod) => {52+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [['ipc']]));53+ t.is(stdout, 'ipc');54+};55+56 test.serial('stdin option can be an array of strings', testIterable, [foobarArray], 0, execa);57 test.serial('stdin option can be an array of strings - sync', testIterable, [foobarArray], 0, execaSync);58 test.serial('stdio[*] option can be an array of strings', testIterable, [foobarArray], 3, execa);59+test.serial('stdin option can be an array with "ipc" as input data', testIpcDataIterable, 0, execa);60+test.serial('stdin option can be an array with "ipc" as input data - sync', testIpcDataIterable, 0, execaSync);61+test.serial('stdio[*] option can be an array with "ipc" as input data', testIpcDataIterable, 3, execa);62 test.serial('stdin option can be an array of Uint8Arrays', testIterable, [binaryArray], 0, execa);63 test.serial('stdin option can be an array of Uint8Arrays - sync', testIterable, [binaryArray], 0, execaSync);64 test.serial('stdio[*] option can be an array of Uint8Arrays', testIterable, [binaryArray], 3, execa);65 test.serial('stdin option can be an iterable of strings', testIterable, stringGenerator(), 0, execa);145 unmodified linesmodified:test-d/return/result-stdio.test-d.ts+6 added
112 unmodified lines113 114 const inputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: true}]});115 expectType<undefined>(inputPipeFd3Result.stdio[3]);116 117+const inputInheritFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'inherit', input: true}]});118+expectType<undefined>(inputInheritFd3Result.stdio[3]);119+120+const inputFdFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 3, input: true}]});121+expectType<undefined>(inputFdFd3Result.stdio[3]);122+123 const outputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe'}]});124 expectType<string>(outputPipeFd3Result.stdio[3]);125 126 const input = true as boolean;30 unmodified linesmodified:test-d/stdio/option/input-pipe.test-d.ts+15 added
1+import {Writable} from 'node:stream';2 import {expectError, expectAssignable} from 'tsd';3 import {4 execa,5 execaSync,5 unmodified lines11 12 const inputPipe = {value: 'pipe', input: true} as const;13 const input = true as boolean;14 const booleanInputPipe = {value: 'pipe', input} as const;15+const transform = function * (line: string) {16+ yield line;17+};18 19 await execa('unicorns', {stdin: inputPipe});20 execaSync('unicorns', {stdin: inputPipe});21 await execa('unicorns', {stdout: inputPipe});12 unmodified lines34 35 expectError(await execa('unicorns', {stdin: {value: 'other', input: true}}));36 expectError(await execa('unicorns', {stdin: {value: 'pipe', input: 'true'}}));37 38+// The `{value, input}` form works with any direction-ambiguous value, not just `'pipe'`/`'overlapped'`.39+await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'inherit', input: true}]});40+await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: new URL('file:///test'), input: true}]});41+await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: {file: './example'}, input: true}]});42+await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: transform, input: true}]});43+expectAssignable<StdinOption>({value: 'inherit', input: true});44+expectAssignable<StdinOption>({value: {file: './example'}, input: true});45+46+// A value with a fixed direction cannot be marked as input.47+expectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: new Writable(), input: true}]}));48+49 expectAssignable<StdinOption>(inputPipe);50 expectAssignable<StdinOption>(booleanInputPipe);51 expectAssignable<StdinSyncOption>(inputPipe);52 expectAssignable<StdinSyncOption>(booleanInputPipe);12 unmodified linesmodified:test-d/subprocess/stdio.test-d.ts+9 added
44 unmodified lines45 46 const outputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe'}]});47 expectType<Readable>(outputPipeSubprocess.stdio[3]);48 49+const inputInheritSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'inherit', input: true}]});50+expectType<null>(inputInheritSubprocess.stdio[3]);51+52+const inputFdSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 3, input: true}]});53+expectType<null>(inputFdSubprocess.stdio[3]);54+55+const inputFileSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: {file: './example'}, input: true}]});56+expectType<Writable>(inputFileSubprocess.stdio[3]);57+58 const input = true as boolean;59 const booleanInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input}]});60 expectType<Readable | Writable>(booleanInputPipeSubprocess.stdio[3]);61 15 unmodified linesmodified:types/stdio/direction.d.ts+8 added-8 removed
1 import type {CommonOptions} from '../arguments/options.js';2 import type {Intersects} from '../utils.js';3-import type {StdioSingleOptionItems, InputStdioOption, NativePipeStdioOption} from './type.js';3+import type {StdioSingleOptionItems, InputStdioOption, AmbiguousStdioOption} from './type.js';4 import type {FdStdioArrayOption} from './option.js';5 6-type AnyNativePipeStdioOption = NativePipeStdioOption<boolean, false>;6+type AnyAmbiguousStdioOption = AmbiguousStdioOption<boolean, false, boolean>;7 8-type InputNativePipeStdioOption = AnyNativePipeStdioOption & {8+type InputAmbiguousStdioOption = AnyAmbiguousStdioOption & {9 readonly input: true;10 };11 12-type NativePipeInputValue<StdioOptionType> = StdioOptionType extends AnyNativePipeStdioOption13- ? NativePipeInputProperty<StdioOptionType>12+type AmbiguousStdioInputValue<StdioOptionType> = StdioOptionType extends AnyAmbiguousStdioOption13+ ? AmbiguousStdioInputProperty<StdioOptionType>14 : never;15 16-type NativePipeInputProperty<StdioOptionType> = 'input' extends keyof StdioOptionType16+type AmbiguousStdioInputProperty<StdioOptionType> = 'input' extends keyof StdioOptionType17 ? StdioOptionType extends {readonly input?: infer Input} ? Input : never18 : never;19 20 // Whether `result.stdio[FdNumber]` is an input stream11 unmodified lines32 FdNumber extends string,33 StdioOptionType,34 > = Intersects<35 StdioOptionType,36- FdNumber extends '1' | '2' ? InputStdioOption : InputStdioOption | InputNativePipeStdioOption36+ FdNumber extends '1' | '2' ? InputStdioOption : InputStdioOption | InputAmbiguousStdioOption37 > extends true38 ? true39 : FdNumber extends '1' | '2'40 ? false41- : true extends NativePipeInputValue<StdioOptionType>41+ : true extends AmbiguousStdioInputValue<StdioOptionType>42 ? boolean43 : false;44 45 export {};modified:types/stdio/type.d.ts+27 added-4 removed
23 unmodified lines24 | number25 | Readable26 | Writable27 | Unless<IsStandardStream<FdNumber>, undefined>28- | readonly [NoStreamStdioOption<FdNumber>];28+ | readonly [NoStreamStdioOption<FdNumber>]29+ | {readonly value: 'inherit' | number; readonly input?: boolean};30 31 // `options.stdio` when it is not an array32 type SimpleStdioOption<33 IsSync extends boolean,5 unmodified lines39 | Unless<And<And<Not<IsSync>, IsArray>, IsExtra>, 'inherit'>40 | Unless<IsArray, 'ignore'>41 | Unless<IsSync, 'overlapped'>;42 43+// The `{value, input}` object form wraps a direction-ambiguous value and sets its direction explicitly.42-export type NativePipeStdioOption<44+export type AmbiguousStdioOption<45 IsSync extends boolean,46 IsExtra extends boolean,47+ IsArray extends boolean,48+ ObjectModeChunk = unknown,49+ TransformChunk = string,50 > = {46- readonly value: 'pipe' | Unless<IsSync, 'overlapped'>;51+ readonly value: AmbiguousStdioValue<IsSync, IsArray, ObjectModeChunk, TransformChunk>;52 readonly input?: Unless<And<IsSync, IsExtra>, boolean> | false;53 };54 55+// Values whose direction is ambiguous on additional file descriptors, so they default to output unless `input` is set.56+// This excludes values with a fixed direction (readable/writable streams, iterables, standard file descriptors).57+type AmbiguousStdioValue<58+ IsSync extends boolean,59+ IsArray extends boolean,60+ ObjectModeChunk,61+ TransformChunk,62+> =63+ | 'pipe'64+ | 'inherit'65+ | Unless<IsSync, 'overlapped'>66+ | URL67+ | GeneratorTransform<IsSync, TransformChunk>68+ | GeneratorTransformFull<IsSync, ObjectModeChunk, TransformChunk>69+ | Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9>70+ | Unless<IsSync, DuplexTransform | WebTransform | TransformStream>71+ | {readonly file: string; readonly append?: boolean};72+73 // Values available in both `options.stdin|stdio` and `options.stdout|stderr|stdio`74 type CommonStdioOption<75 IsSync extends boolean,76 IsExtra extends boolean,1 unmodified line78 ObjectModeChunk = unknown,79 TransformChunk = string,80 > =81 // TypeScript cannot contextually type inline full generator transform objects through this broad stdio union because the union also includes `{transform: Duplex | TransformStream}` wrapper objects. Users should annotate `chunk` when assigning an inline object directly to `StdinOption`, `StdoutStderrOption`, `Options['stdout']`, etc. Keep `GeneratorTransformFull` mode branches narrow, but do not add a broad full-object fallback here to try to recover contextual typing.59- SimpleStdioOption<IsSync, IsExtra, IsArray> | URL | GeneratorTransform<IsSync, TransformChunk> | GeneratorTransformFull<IsSync, ObjectModeChunk, TransformChunk> | Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9> | Unless<IsSync, DuplexTransform | WebTransform | TransformStream> | NativePipeStdioOption<IsSync, IsExtra> | {readonly file: string; readonly append?: boolean};82+ SimpleStdioOption<IsSync, IsExtra, IsArray> | URL | GeneratorTransform<IsSync, TransformChunk> | GeneratorTransformFull<IsSync, ObjectModeChunk, TransformChunk> | Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9> | Unless<IsSync, DuplexTransform | WebTransform | TransformStream> | AmbiguousStdioOption<IsSync, IsExtra, IsArray, ObjectModeChunk, TransformChunk> | {readonly file: string; readonly append?: boolean};83 84 // Synchronous iterables excluding strings, Uint8Arrays and Arrays85 type IterableObject<IsArray extends boolean> = Iterable<unknown>86 & object120 unmodified lines