Skip to content
Myr

generator-string.test-d.ts

This file

Path

test-d/stdio/option/generator-string.test-d.ts

57 lines · 2.3 KiB · TypeScript

Last changed by

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

History of this file

Take it

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

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 1why, one step back
1import {expectTypeOf, expectError} from 'nz';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 2–14why, one step back
2import {
3 execa,4 execaSync,5 type StdinOption,6 type StdinSyncOption,7 type StdoutStderrOption,8 type StdoutStderrSyncOption,9} from '../../../index.js';1011const stringGenerator = function * (line: string) {12 yield line;13};14

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

lines 15–18why, one step back
15await execa('unicorns', {stdin: stringGenerator});
16execaSync('unicorns', {stdin: stringGenerator});17await execa('unicorns', {stdin: [stringGenerator]});18execaSync('unicorns', {stdin: [stringGenerator]});

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 19why, one step back
19

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

lines 20–23why, one step back
20await execa('unicorns', {stdout: stringGenerator});
21execaSync('unicorns', {stdout: stringGenerator});22await execa('unicorns', {stdout: [stringGenerator]});23execaSync('unicorns', {stdout: [stringGenerator]});

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 24why, one step back
24

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

lines 25–28why, one step back
25await execa('unicorns', {stderr: stringGenerator});
26execaSync('unicorns', {stderr: stringGenerator});27await execa('unicorns', {stderr: [stringGenerator]});28execaSync('unicorns', {stderr: [stringGenerator]});

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 29–32why, one step back
29
30expectError(await execa('unicorns', {stdio: stringGenerator}));31expectError(execaSync('unicorns', {stdio: stringGenerator}));32

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

lines 33–36why, one step back
33await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringGenerator]});
34execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringGenerator]});35await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringGenerator]]});36execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringGenerator]]});

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 37why, one step back
37

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 38–41why, one step back
38expectTypeOf(stringGenerator).toBeAssignableTo<StdinOption>();
39expectTypeOf(stringGenerator).toBeAssignableTo<StdinSyncOption>();40[stringGenerator] satisfies StdinOption;41[stringGenerator] satisfies StdinSyncOption;

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 42why, one step back
42

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 43–46why, one step back
43expectTypeOf(stringGenerator).toBeAssignableTo<StdoutStderrOption>();
44expectTypeOf(stringGenerator).toBeAssignableTo<StdoutStderrSyncOption>();45[stringGenerator] satisfies StdoutStderrOption;46[stringGenerator] satisfies StdoutStderrSyncOption;

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

lines 47–53why, one step back
47
48// The `chunk` argument is typed, but the return type stays `unknown`: a transform can yield both `string` and `Uint8Array`.49const mixedYieldGenerator = function * (line: string) {50 yield line;51 yield new TextEncoder().encode(line);52};53

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 54–57why, one step back
54expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdinOption>();
55expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdinSyncOption>();56expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdoutStderrOption>();57expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdoutStderrSyncOption>();