Skip to content
Myr

script.test-d.ts

This file

Path

test-d/methods/script.test-d.ts

56 lines · 2.7 KiB · TypeScript

Last changed by

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

History of this file

Take it

Split type files (#978)ehmickybefore adoption0bd0f0d

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

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 2why, one step back
2import {$, type ExecaResult, type ExecaResultPromise} from '../../index.js';

Split type files (#978)ehmickybefore adoption0bd0f0d

lines 3–9why, one step back
3
4const fileUrl = new URL('file:///test');5const stringArray = ['foo', 'bar'] as const;67expectError($());8expectError($(true));9expectError($(['unicorns', 'arg']));

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 10–11why, one step back
10expectAssignable<ExecaResultPromise>($('unicorns'));
11expectAssignable<ExecaResultPromise>($(fileUrl));

Split type files (#978)ehmickybefore adoption0bd0f0d

line 12why, one step back
12

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 13–14why, one step back
13expectAssignable<ExecaResultPromise>($('unicorns', []));
14expectAssignable<ExecaResultPromise>($('unicorns', ['foo']));

Split type files (#978)ehmickybefore adoption0bd0f0d

lines 15–17why, one step back
15expectError($('unicorns', 'foo'));
16expectError($('unicorns', [true]));17

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 18–19why, one step back
18expectAssignable<ExecaResultPromise>($('unicorns', {}));
19expectAssignable<ExecaResultPromise>($('unicorns', [], {}));

Split type files (#978)ehmickybefore adoption0bd0f0d

lines 20–22why, one step back
20expectError($('unicorns', [], []));
21expectError($('unicorns', {other: true}));22

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 23why, one step back
23expectAssignable<ExecaResultPromise>($`unicorns`);

Split type files (#978)ehmickybefore adoption0bd0f0d

lines 24–27why, one step back
24expectType<ExecaResult<{}>>(await $('unicorns'));
25expectType<ExecaResult<{}>>(await $`unicorns`);2627expectAssignable<typeof $>($({}));

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 28–29why, one step back
28expectAssignable<ExecaResultPromise>($({})('unicorns'));
29expectAssignable<ExecaResultPromise>($({})`unicorns`);

Split type files (#978)ehmickybefore adoption0bd0f0d

lines 30–56why, one step back
30
31expectAssignable<{stdout: string}>(await $('unicorns'));32expectAssignable<{stdout: Uint8Array}>(await $('unicorns', {encoding: 'buffer'}));33expectAssignable<{stdout: string}>(await $('unicorns', ['foo']));34expectAssignable<{stdout: Uint8Array}>(await $('unicorns', ['foo'], {encoding: 'buffer'}));35expectAssignable<{stdout: string}>(await $({})('unicorns'));36expectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})('unicorns'));37expectAssignable<{stdout: Uint8Array}>(await $({})({encoding: 'buffer'})('unicorns'));38expectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})({})('unicorns'));39expectAssignable<{stdout: string}>(await $({})`unicorns`);40expectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})`unicorns`);41expectAssignable<{stdout: Uint8Array}>(await $({})({encoding: 'buffer'})`unicorns`);42expectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})({})`unicorns`);4344expectType<ExecaResult<{}>>(await $`${'unicorns'}`);45expectType<ExecaResult<{}>>(await $`unicorns ${'foo'}`);46expectType<ExecaResult<{}>>(await $`unicorns ${'foo'} ${'bar'}`);47expectType<ExecaResult<{}>>(await $`unicorns ${1}`);48expectType<ExecaResult<{}>>(await $`unicorns ${stringArray}`);49expectType<ExecaResult<{}>>(await $`unicorns ${[1, 2]}`);50expectType<ExecaResult<{}>>(await $`unicorns ${false.toString()}`);51expectError(await $`unicorns ${false}`);5253expectType<ExecaResult<{}>>(await $`unicorns ${await $`echo foo`}`);54expectError(await $`unicorns ${$`echo foo`}`);55expectType<ExecaResult<{}>>(await $`unicorns ${[await $`echo foo`, 'bar']}`);56expectError(await $`unicorns ${[$`echo foo`, 'bar']}`);