Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve types of childProcess.stdout and childProcess.stderr #687

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Jan 14, 2024

Follow-up on #681.

While #681 fixed the types of result.stdout|stderr, this PR fixes the types of childProcess.stdout|stderr.

childProcess.stdout|stderr is null when using options like stdout: 'inherit'. Otherwise it is a Readable stream.

This PR does not fix childProcess.all yet.

export type ExecaChildPromise<OptionsType extends Options = Options> = {
stdout: StreamUnlessIgnored<'1', OptionsType>;

stderr: StreamUnlessIgnored<'2', OptionsType>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving the documentation blank as we do not document this property.
Since the final type uses & ChildProcess, it turns out childProcess.stdout|stderr still shows the TypeScript documentation for it coming from Node.js' ChildProcess.

type StreamUnlessIgnored<
StreamIndex extends string,
OptionsType extends Options = Options,
> = IgnoresStreamResult<StreamIndex, OptionsType> extends true ? null : Readable;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: ChildProcess["stdout"] type is Readable | null.

@sindresorhus sindresorhus merged commit 8062913 into main Jan 14, 2024
14 checks passed
@sindresorhus sindresorhus deleted the child-process-ignored branch January 14, 2024 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants