Open
Description
IxJS version: 7.0.0
Code to reproduce: https://codesandbox.io/p/sandbox/typescript-playground-export-forked-9jmsj9?workspaceId=ws_TdkXAMqyc14LovZfzuJaP6
import { AsyncIterableX, from } from "ix/asynciterable";
import { tap } from "ix/asynciterable/operators";
import {
MonoTypeOperatorAsyncFunction,
MonoTypeOperatorFunction,
} from "ix/interfaces";
import { IterableX } from "ix/iterable";
declare const sync: IterableX<number>;
declare const async: AsyncIterableX<number>;
declare const syncOp: MonoTypeOperatorFunction<string>;
declare const asyncOp: MonoTypeOperatorAsyncFunction<string>;
sync.pipe(syncOp);
// ~~~~~~ Errors, as it should
async.pipe(asyncOp);
// ^^^^^^^ No error!
// Demo, will crash at runtime
from([1, 2, 3]).pipe(tap((val: string) => val.length));
Expected behavior: The function signature should prevent piping an AsyncIterable<number>
into an operator that expects string
. The attached code demonstrates how this could end up bad.
Actual behavior: According to TS, the expression is a-ok for async iterables. Note that it works as intended for sync iterables.
Additional information:
Metadata
Metadata
Assignees
Labels
No labels