Fix types of `reject` option (#688)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent ae64408 · Browse files · 2 files·+32 added−4 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−4 removed
- other:+32 added−4 removed
Provenance
- Commit
0438d35- Tree
5d06f45- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
ae64408
2 files changed+32 added−4 removed
modified:index.d.ts+8 added-4 removed
611 unmodified lines612 */613 all: AllOutput<OptionsType>;614 });615 616-export type ExecaReturnValue<OptionsType extends Options = Options> = ExecaCommonReturnValue<false, OptionsType>;617-export type ExecaSyncReturnValue<OptionsType extends SyncOptions = SyncOptions> = ExecaCommonReturnValue<true, OptionsType>;616+export type ExecaReturnValue<OptionsType extends Options = Options> = ExecaCommonReturnValue<false, OptionsType> & ErrorUnlessReject<OptionsType['reject']>;617+export type ExecaSyncReturnValue<OptionsType extends SyncOptions = SyncOptions> = ExecaCommonReturnValue<true, OptionsType> & ErrorUnlessReject<OptionsType['reject']>;618 619+type ErrorUnlessReject<RejectOption extends CommonOptions['reject']> = RejectOption extends false620+ ? Partial<ExecaCommonError>621+ : {};622+623 type ExecaCommonError = {624 /**625 Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.626 13 unmodified lines640 */641 originalMessage?: string;642 } & Error;643 640-export type ExecaError<OptionsType extends Options = Options> = ExecaCommonError & ExecaReturnValue<OptionsType>;641-export type ExecaSyncError<OptionsType extends SyncOptions = SyncOptions> = ExecaCommonError & ExecaSyncReturnValue<OptionsType>;644+export type ExecaError<OptionsType extends Options = Options> = ExecaCommonReturnValue<false, OptionsType> & ExecaCommonError;645+export type ExecaSyncError<OptionsType extends SyncOptions = SyncOptions> = ExecaCommonReturnValue<true, OptionsType> & ExecaCommonError;646 647 export type KillOptions = {648 /**649 Milliseconds to wait for the child process to terminate before sending `SIGKILL`.551 unmodified linesmodified:index.test-d.ts+24 added
368 unmodified lines369 expectType<undefined>(streamStderrError.stderr);370 expectType<string>(streamStderrError.all);371 }372 373+const rejectsResult = await execa('unicorns');374+expectError(rejectsResult.stack);375+expectError(rejectsResult.message);376+expectError(rejectsResult.shortMessage);377+expectError(rejectsResult.originalMessage);378+379+const noRejectsResult = await execa('unicorns', {reject: false});380+expectType<string | undefined>(noRejectsResult.stack);381+expectType<string | undefined>(noRejectsResult.message);382+expectType<string | undefined>(noRejectsResult.shortMessage);383+expectType<string | undefined>(noRejectsResult.originalMessage);384+385 try {386 const unicornsResult = execaSync('unicorns');387 388 expectAssignable<ExecaSyncReturnValue>(unicornsResult);140 unmodified lines529 expectType<undefined>(numberStderrError.stderr);530 expectError(numberStderrError.all);531 }532 533+const rejectsSyncResult = execaSync('unicorns');534+expectError(rejectsSyncResult.stack);535+expectError(rejectsSyncResult.message);536+expectError(rejectsSyncResult.shortMessage);537+expectError(rejectsSyncResult.originalMessage);538+539+const noRejectsSyncResult = execaSync('unicorns', {reject: false});540+expectType<string | undefined>(noRejectsSyncResult.stack);541+expectType<string | undefined>(noRejectsSyncResult.message);542+expectType<string | undefined>(noRejectsSyncResult.shortMessage);543+expectType<string | undefined>(noRejectsSyncResult.originalMessage);544+545 const stringGenerator = function * () {546 yield '';547 };548 536 unmodified lines