ReactiveX / IxJS

The Interactive Extensions for JavaScript
https://reactivex.io/IxJS/
MIT License
1.33k stars 74 forks source link

Build errors with Typescript 4.7.4 #345

Closed WorldMaker closed 11 months ago

WorldMaker commented 2 years ago

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.

domoritz commented 11 months ago

Looks like there are more errors with 5.3.2. I get this error in a downstream project

node_modules/ix/asynciterable/asasynciterable.d.ts:5:18 - error TS2320: Interface 'AsyncIterableTransform<T>' cannot simultaneously extend types 'Transform' and 'AsyncIterableX<T>'.
  Named property 'every' of types 'Transform' and 'AsyncIterableX<T>' are not identical.

5 export interface AsyncIterableTransform<T> extends AsyncIterableX<T>, Transform {
...
domoritz commented 7 months ago

Could you make a new release so that we get this fix in arrow?

trxcllnt commented 7 months ago

@domoritz yes I can

domoritz commented 7 months ago

Great, let me know and I'll update the dependency in arrow to remove the type errors.