Skip to content
Myr

command.test-d.ts

This file

Path

test-d/methods/command.test-d.ts

100 lines · 5.3 KiB · TypeScript

Last changed by

Upgrade xo (#980)ehmickybefore adoptionccfa412

History of this file

Take it

Split type files (#978)ehmickybefore adoption0bd0f0d

line 1why, one step back
1import {expectType, expectError, expectAssignable} from 'tsd';

Upgrade xo (#980)ehmickybefore adoptionccfa412

lines 2–8why, one step back
2import {
3 execaCommand,4 execaCommandSync,5 type ExecaResult,6 type ExecaSubprocess,7 type ExecaSyncResult,8} from '../../index.js';

Split type files (#978)ehmickybefore adoption0bd0f0d

lines 9–100why, one step back
9
10const fileUrl = new URL('file:///test');11const stringArray = ['foo', 'bar'] as const;1213expectError(execaCommand());14expectError(execaCommand(true));15expectError(execaCommand(['unicorns', 'arg']));16expectAssignable<ExecaSubprocess>(execaCommand('unicorns'));17expectError(execaCommand(fileUrl));1819expectError(execaCommand('unicorns', []));20expectError(execaCommand('unicorns', ['foo']));21expectError(execaCommand('unicorns', 'foo'));22expectError(execaCommand('unicorns', [true]));2324expectAssignable<ExecaSubprocess>(execaCommand('unicorns', {}));25expectError(execaCommand('unicorns', [], {}));26expectError(execaCommand('unicorns', [], []));27expectError(execaCommand('unicorns', {other: true}));2829expectAssignable<ExecaSubprocess>(execaCommand`unicorns`);30expectType<ExecaResult<{}>>(await execaCommand('unicorns'));31expectType<ExecaResult<{}>>(await execaCommand`unicorns`);3233expectAssignable<typeof execaCommand>(execaCommand({}));34expectAssignable<ExecaSubprocess>(execaCommand({})('unicorns'));35expectAssignable<ExecaSubprocess>(execaCommand({})`unicorns`);3637expectAssignable<{stdout: string}>(await execaCommand('unicorns'));38expectAssignable<{stdout: Uint8Array}>(await execaCommand('unicorns', {encoding: 'buffer'}));39expectAssignable<{stdout: string}>(await execaCommand({})('unicorns'));40expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})('unicorns'));41expectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})('unicorns'));42expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})('unicorns'));43expectAssignable<{stdout: string}>(await execaCommand({})`unicorns`);44expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})`unicorns`);45expectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})`unicorns`);46expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})`unicorns`);4748expectType<ExecaResult<{}>>(await execaCommand`${'unicorns'}`);49expectType<ExecaResult<{}>>(await execaCommand`unicorns ${'foo'}`);50expectError(await execaCommand`unicorns ${'foo'} ${'bar'}`);51expectError(await execaCommand`unicorns ${1}`);52expectError(await execaCommand`unicorns ${stringArray}`);53expectError(await execaCommand`unicorns ${[1, 2]}`);54expectType<ExecaResult<{}>>(await execaCommand`unicorns ${false.toString()}`);55expectError(await execaCommand`unicorns ${false}`);5657expectError(await execaCommand`unicorns ${await execaCommand`echo foo`}`);58expectError(await execaCommand`unicorns ${execaCommand`echo foo`}`);59expectError(await execaCommand`unicorns ${[await execaCommand`echo foo`, 'bar']}`);60expectError(await execaCommand`unicorns ${[execaCommand`echo foo`, 'bar']}`);6162expectError(execaCommandSync());63expectError(execaCommandSync(true));64expectError(execaCommandSync(['unicorns', 'arg']));65expectType<ExecaSyncResult<{}>>(execaCommandSync('unicorns'));66expectError(execaCommandSync(fileUrl));67expectError(execaCommandSync('unicorns', []));68expectError(execaCommandSync('unicorns', ['foo']));69expectType<ExecaSyncResult<{}>>(execaCommandSync('unicorns', {}));70expectError(execaCommandSync('unicorns', [], {}));71expectError(execaCommandSync('unicorns', 'foo'));72expectError(execaCommandSync('unicorns', [true]));73expectError(execaCommandSync('unicorns', [], []));74expectError(execaCommandSync('unicorns', {other: true}));75expectType<ExecaSyncResult<{}>>(execaCommandSync`unicorns`);76expectAssignable<typeof execaCommandSync>(execaCommandSync({}));77expectType<ExecaSyncResult<{}>>(execaCommandSync({})('unicorns'));78expectType<ExecaSyncResult<{}>>(execaCommandSync({})`unicorns`);79expectType<ExecaSyncResult<{}>>(execaCommandSync('unicorns'));80expectType<ExecaSyncResult<{}>>(execaCommandSync`unicorns`);81expectAssignable<{stdout: string}>(execaCommandSync('unicorns'));82expectAssignable<{stdout: Uint8Array}>(execaCommandSync('unicorns', {encoding: 'buffer'}));83expectAssignable<{stdout: string}>(execaCommandSync({})('unicorns'));84expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})('unicorns'));85expectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})('unicorns'));86expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})('unicorns'));87expectAssignable<{stdout: string}>(execaCommandSync({})`unicorns`);88expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})`unicorns`);89expectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})`unicorns`);90expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})`unicorns`);91expectType<ExecaSyncResult<{}>>(execaCommandSync`${'unicorns'}`);92expectType<ExecaSyncResult<{}>>(execaCommandSync`unicorns ${'foo'}`);93expectError(execaCommandSync`unicorns ${'foo'} ${'bar'}`);94expectError(execaCommandSync`unicorns ${1}`);95expectError(execaCommandSync`unicorns ${stringArray}`);96expectError(execaCommandSync`unicorns ${[1, 2]}`);97expectError(execaCommandSync`unicorns ${execaCommandSync`echo foo`}`);98expectError(execaCommandSync`unicorns ${[execaCommandSync`echo foo`, 'bar']}`);99expectType<ExecaSyncResult<{}>>(execaCommandSync`unicorns ${false.toString()}`);100expectError(execaCommandSync`unicorns ${false}`);