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 fileTake 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 back1import {expectTypeOf, expectError} from 'nz';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 2–14why, one step back2import {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};14Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8
lines 15–18why, one step back15await 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 back19Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8
lines 20–23why, one step back20await 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 back24Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8
lines 25–28why, one step back25await 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 back2930expectError(await execa('unicorns', {stdio: stringGenerator}));31expectError(execaSync('unicorns', {stdio: stringGenerator}));32Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8
lines 33–36why, one step back33await 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 back37Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 38–41why, one step back38expectTypeOf(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 back42Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 43–46why, one step back43expectTypeOf(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 back4748// 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};53Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 54–57why, one step back54expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdinOption>();55expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdinSyncOption>();56expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdoutStderrOption>();57expectTypeOf(mixedYieldGenerator).toBeAssignableTo<StdoutStderrSyncOption>();