IxJS icon indicating copy to clipboard operation
IxJS copied to clipboard

Build errors with Typescript 4.7.4

Open WorldMaker opened this issue 2 years ago • 0 comments

IxJS version: 4.5.2

Code to reproduce:

Using @reactivex/ix-ts in webpack (4) with fork-ts-checker-webpack-plugin (6) and Typescript (4.7.4).

tsconfig.json excerpt:

{
  "compilerOptions": {
    "lib": ["dom", "es2015", "es2015.iterable", "esnext.asynciterable"],
    "downlevelIteration": true
  }
}

Expected behavior:

Compiles without errors originating in node_modules/@reactivex/ix-ts.

Actual behavior:

ERROR in node_modules/@reactivex/ix-ts/asynciterable/asynciterablex.ts:173:35
TS2339: Property 'toNodeStream' does not exist on type 'AsyncIterableX<any>'.
    171 |           // prettier-ignore
    172 |           return isReadableNodeStream(prev) ? prev.pipe(next, {end}) :
  > 173 |             asAsyncIterable(prev).toNodeStream(readableOpts(next)).pipe(next, {end});
        |                                   ^^^^^^^^^^^^
    174 |         }
    175 |       }
    176 |       return prev;

ERROR in node_modules/@reactivex/ix-ts/asynciterable/operators/withabort.ts:19:47
TS2554: Expected 0 arguments, but got 1.
    17 |
    18 |   [Symbol.asyncIterator](): AsyncIterator<TSource> {
  > 19 |     return this._source[Symbol.asyncIterator](this._signal);
    20 |   }
    21 | }
    22 |

ERROR in node_modules/@reactivex/ix-ts/iterable/iterablex.ts:142:30
TS2339: Property 'toNodeStream' does not exist on type 'IterableX<any>'.
    140 |           // prettier-ignore
    141 |           return isReadableNodeStream(prev) ? prev.pipe(next, {end}) :
  > 142 |             asIterable(prev).toNodeStream(readableOpts(next)).pipe(next, {end});
        |                              ^^^^^^^^^^^^
    143 |         }
    144 |       }
    145 |       return prev;

Additional information:

The two toNodeStream errors are wrapped in if (isBrowser) blocks so it looks like a simple type leakage from a node lib? Maybe just needs an as any to avoid assuming Node types are available? (Or // @ts-ignore; I don't know how that combines with // prettier-ignore, though.)

The withabort error seems like a simple type fix, perhaps:

private _source: AsyncIterableX<TSource>

Comparing this operator version with the non-operator version in asynciterablex.ts it looks like the difference is instead a // @ts-ignore above the currently erroring line.

WorldMaker avatar Jul 07 '22 01:07 WorldMaker