Skip to content
Myr

script.test-d.ts

This file

Path

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

64 lines · 2.8 KiB · TypeScript

Last changed by

Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8

History of this file

Take it

The walk stopped after 200 commits: lines older than c8a6ed7 point at it.

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

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

Rename some types (#1009)ehmickybefore adoption2ef9186

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

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

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']));

Rename some types (#1009)ehmickybefore adoption2ef9186

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

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

line 12why, one step back
12

Rename some types (#1009)ehmickybefore adoption2ef9186

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

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

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

Rename some types (#1009)ehmickybefore adoption2ef9186

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

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

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

Rename some types (#1009)ehmickybefore adoption2ef9186

lines 23–25why, one step back
23expectAssignable<ResultPromise>($`unicorns`);
24expectType<Result<{}>>(await $('unicorns'));25expectType<Result<{}>>(await $`unicorns`);

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

lines 26–27why, one step back
26
27expectAssignable<typeof $>($({}));

Rename some types (#1009)ehmickybefore adoption2ef9186

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

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

lines 30–43why, 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`);43

Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8

lines 44–50why, one step back
44const uint8ArrayGenerator = function * (chunk: Uint8Array) {
45 yield chunk;46};4748expectError($({encoding: 'utf8', stdout: uint8ArrayGenerator}));49$({encoding: 'buffer', stdout: uint8ArrayGenerator});50

Rename some types (#1009)ehmickybefore adoption2ef9186

lines 51–57why, one step back
51expectType<Result<{}>>(await $`${'unicorns'}`);
52expectType<Result<{}>>(await $`unicorns ${'foo'}`);53expectType<Result<{}>>(await $`unicorns ${'foo'} ${'bar'}`);54expectType<Result<{}>>(await $`unicorns ${1}`);55expectType<Result<{}>>(await $`unicorns ${stringArray}`);56expectType<Result<{}>>(await $`unicorns ${[1, 2]}`);57expectType<Result<{}>>(await $`unicorns ${false.toString()}`);

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

lines 58–59why, one step back
58expectError(await $`unicorns ${false}`);
59

Rename some types (#1009)ehmickybefore adoption2ef9186

line 60why, one step back
60expectType<Result<{}>>(await $`unicorns ${await $`echo foo`}`);

Fix type of result when using the `reject: false` option (#1046)ehmickybefore adoptionab2a9ed

line 61why, one step back
61expectType<Result<{}>>(await $`unicorns ${await $({reject: false})`echo foo`}`);

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

line 62why, one step back
62expectError(await $`unicorns ${$`echo foo`}`);

Rename some types (#1009)ehmickybefore adoption2ef9186

line 63why, one step back
63expectType<Result<{}>>(await $`unicorns ${[await $`echo foo`, 'bar']}`);

Improve documentation (#1003)ehmickybefore adoptionc8a6ed7

line 64why, one step back
64expectError(await $`unicorns ${[$`echo foo`, 'bar']}`);