Skip to content
Myr

Fix type of `childProcess.all` (#689)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 0438d35 · Browse files · 2 files+32 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+32 added−3 removed

  • other:+32 added−3 removed

2 files+32 added−3 removed

modified:index.d.ts+21 added-1 removed
662 unmodified lines
663type ChildProcessStream<StreamResultIgnored extends boolean> = StreamResultIgnored extends true664 ? null665 : Readable;666667type AllStream<OptionsType extends Options = Options> = AllStreamProperty<OptionsType['all'], OptionsType>;668669type AllStreamProperty<670 AllOption extends Options['all'] = Options['all'],671 OptionsType extends Options = Options,672> = AllOption extends true673 ? AllIfStdout<IgnoresStreamResult<'1', OptionsType>, OptionsType>674 : undefined;675676type AllIfStdout<677 StdoutResultIgnored extends boolean,678 OptionsType extends Options = Options,679> = StdoutResultIgnored extends true680 ? AllIfStderr<IgnoresStreamResult<'2', OptionsType>>681 : Readable;682683type AllIfStderr<StderrResultIgnored extends boolean> = StderrResultIgnored extends true684 ? undefined685 : Readable;686687export type ExecaChildPromise<OptionsType extends Options = Options> = {688 stdout: StreamUnlessIgnored<'1', OptionsType>;689690 stderr: StreamUnlessIgnored<'2', OptionsType>;
4 unmodified lines
695 This is `undefined` if either:696 - the `all` option is `false` (the default value)697 - both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)698 */679 all?: Readable;699 all: AllStream<OptionsType>;700701 catch<ResultType = never>(702 onRejected?: (reason: ExecaError<OptionsType>) => ResultType | PromiseLike<ResultType>703 ): Promise<ExecaReturnValue<OptionsType> | ResultType>;
517 unmodified lines
modified:index.test-d.ts+11 added-2 removed
21 unmodified lines
22} from './index.js';2324expectType<Readable | null>({} as ExecaChildProcess['stdout']);25expectType<Readable | null>({} as ExecaChildProcess['stderr']);26expectType<Readable | undefined>({} as ExecaChildProcess['all']);27expectType<string | Uint8Array | undefined>({} as ExecaReturnValue['stdout']);28expectType<string | Uint8Array | undefined>({} as ExecaReturnValue['stderr']);29expectType<string | Uint8Array | undefined>({} as ExecaReturnValue['all']);30expectType<[undefined, string | Uint8Array | undefined, string | Uint8Array | undefined]>({} as ExecaReturnValue['stdio']);
37 unmodified lines
68 expectAssignable<ExecaChildProcess>(execaPromise.pipeAll!(execaBufferPromise));69 expectAssignable<ExecaChildProcess>(execaBufferPromise.pipeAll!(execaPromise));70 expectAssignable<ExecaChildProcess>(execaBufferPromise.pipeAll!(execaBufferPromise));7171 expectType<Readable | undefined>(execaPromise.all);72 expectType<Readable>(execaPromise.all);73 const noAllPromise = execa('unicorns');73 expectType<Readable | undefined>(noAllPromise.all);74 expectType<undefined>(noAllPromise.all);75 const noAllResult = await noAllPromise;76 expectType<undefined>(noAllResult.all);7778 const unicornsResult = await execaPromise;
17 unmodified lines
96 expectType<string | undefined>(unicornsResult.stdio[3 as number]);9798 expectType<Readable>(execaBufferPromise.stdout);99 expectType<Readable>(execaBufferPromise.stderr);100 expectType<Readable>(execaBufferPromise.all);101 const bufferResult = await execaBufferPromise;102 expectType<Uint8Array>(bufferResult.stdout);103 expectType<Uint8Array>(bufferResult.stdio[1]);104 expectType<Uint8Array>(bufferResult.stderr);
2 unmodified lines
107108 const noBufferPromise = execa('unicorns', {buffer: false, all: true});109 expectType<Readable>(noBufferPromise.stdout);110 expectType<Readable>(noBufferPromise.stderr);111 expectType<Readable>(noBufferPromise.all);112 const noBufferResult = await noBufferPromise;113 expectType<undefined>(noBufferResult.stdout);114 expectType<undefined>(noBufferResult.stdio[1]);115 expectType<undefined>(noBufferResult.stderr);
2 unmodified lines
118119 const multipleStdoutPromise = execa('unicorns', {stdout: ['inherit', 'pipe'] as ['inherit', 'pipe'], all: true});120 expectType<Readable>(multipleStdoutPromise.stdout);121 expectType<Readable>(multipleStdoutPromise.stderr);122 expectType<Readable>(multipleStdoutPromise.all);123 const multipleStdoutResult = await multipleStdoutPromise;124 expectType<string>(multipleStdoutResult.stdout);125 expectType<string>(multipleStdoutResult.stdio[1]);126 expectType<string>(multipleStdoutResult.stderr);
2 unmodified lines
129130 const ignoreBothPromise = execa('unicorns', {stdout: 'ignore', stderr: 'ignore', all: true});131 expectType<null>(ignoreBothPromise.stdout);132 expectType<null>(ignoreBothPromise.stderr);133 expectType<undefined>(ignoreBothPromise.all);134 const ignoreBothResult = await ignoreBothPromise;135 expectType<undefined>(ignoreBothResult.stdout);136 expectType<undefined>(ignoreBothResult.stdio[1]);137 expectType<undefined>(ignoreBothResult.stderr);
2 unmodified lines
140141 const ignoreAllPromise = execa('unicorns', {stdio: 'ignore', all: true});142 expectType<null>(ignoreAllPromise.stdout);143 expectType<null>(ignoreAllPromise.stderr);144 expectType<undefined>(ignoreAllPromise.all);145 const ignoreAllResult = await ignoreAllPromise;146 expectType<undefined>(ignoreAllResult.stdout);147 expectType<undefined>(ignoreAllResult.stdio[1]);148 expectType<undefined>(ignoreAllResult.stderr);
2 unmodified lines
151152 const ignoreStdioArrayPromise = execa('unicorns', {stdio: ['pipe', 'ignore', 'pipe'], all: true});153 expectType<null>(ignoreStdioArrayPromise.stdout);154 expectType<Readable>(ignoreStdioArrayPromise.stderr);155 expectType<Readable>(ignoreStdioArrayPromise.all);156 const ignoreStdioArrayResult = await ignoreStdioArrayPromise;157 expectType<undefined>(ignoreStdioArrayResult.stdout);158 expectType<undefined>(ignoreStdioArrayResult.stdio[1]);159 expectType<string>(ignoreStdioArrayResult.stderr);
2 unmodified lines
162163 const ignoreStdoutPromise = execa('unicorns', {stdout: 'ignore', all: true});164 expectType<null>(ignoreStdoutPromise.stdout);165 expectType<Readable>(ignoreStdoutPromise.stderr);166 expectType<Readable>(ignoreStdoutPromise.all);167 const ignoreStdoutResult = await ignoreStdoutPromise;168 expectType<undefined>(ignoreStdoutResult.stdout);169 expectType<string>(ignoreStdoutResult.stderr);170 expectType<string>(ignoreStdoutResult.all);
5 unmodified lines
176177 const ignoreStderrPromise = execa('unicorns', {stderr: 'ignore', all: true});178 expectType<Readable>(ignoreStderrPromise.stdout);179 expectType<null>(ignoreStderrPromise.stderr);180 expectType<Readable>(ignoreStderrPromise.all);181 const ignoreStderrResult = await ignoreStderrPromise;182 expectType<string>(ignoreStderrResult.stdout);183 expectType<undefined>(ignoreStderrResult.stderr);184 expectType<string>(ignoreStderrResult.all);
909 unmodified lines