Rxjs: TypeScript 3.6 compatibility

Created on 30 Sep 2019  Â·  9Comments  Â·  Source: ReactiveX/rxjs

RxJS does not compile with TypeScript 3.6.

Here's a list of issues and (presumed) problems that need to be fixed:

  • [ ] NodeJS typings are out of date, contain conflicting type for IteratorResult
node_modules/@types/node/index.d.ts:74:11 - error TS2300: Duplicate identifier 'IteratorResult'.

74 interface IteratorResult<T> { }
             ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.
...
  • [ ] from(ObservableInput<T> val) in TypeScript 3.6 no longer resolves to Observable<T>, but to Observable<unknown>. I don't know why exactly, but it looks as if TS resolves the call to the overload export function from<O extends ObservableInput<T>, T=any>(input: O): Observable<ObservedValueOf<O>>;, then resolving type ObservedValueOf<T> = O extends ObservableInput<infer T> ? T : never fails.
src/internal/observable/using.ts:55:43 - error TS2769: No overload matches this call.
  Overload 1 of 5, '(observer?: PartialObserver<unknown>): Subscription', gave the following error.
    Argument of type 'Subscriber<T>' is not assignable to parameter of type 'PartialObserver<unknown>'.
      Type 'Subscriber<T>' is not assignable to type 'CompletionObserver<unknown>'.
        Types of property 'next' are incompatible.
          Type '(value?: T) => void' is not assignable to type '(value: unknown) => void'.
            Types of parameters 'value' and 'value' are incompatible.
              Type 'unknown' is not assignable to type 'T'.
                'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
  Overload 2 of 5, '(next?: (value: unknown) => void, error?: (error: any) => void, complete?: () => void): Subscription', gave the following error.
    Argument of type 'Subscriber<T>' is not assignable to parameter of type '(value: unknown) => void'.
      Type 'Subscriber<T>' provides no match for the signature '(value: unknown): void'.

55     const subscription = source.subscribe(subscriber);
                                             ~~~~~~~~~~

Same (?) issue in src/internal/operators/mergeAll.ts and src/internal/operators/switchAll.ts, src/internal/observable/defer.ts, src/internal/operators/switchMapTo.ts.

  • [ ] windowTime uses isNumeric, but should probably use typeof === 'number'. isNumeric returns true for strings that contain a number.
src/internal/operators/windowTime.ts:115:5 - error TS2322: Type 'string | number' is not assignable to type 'number'.
  Type 'string' is not assignable to type 'number'.

115     maxWindowSize = arguments[2];
        ~~~~~~~~~~~~~
TS types

All 9 comments

/CC @DanielRosenwasser is the resolution issue with Observable<ObservedValueOf<O>> a known issue, intended or not?

Regarding from, I wasn't aware of - or I'd overlooked - the presence of this signature:

export function from<O extends ObservableInput<T>, T=any>(input: O): ...

IMO, signatures that encourage the explicit specification of type arguments - which is what this signature does, with its T type parameter - should be avoided. I'd like to see this replaced/deprecated.

Regarding isNumeric, IMO, if it's going to be used to allow numeric strings to be passed - do we really want to continue to do this in future versions? I'd like to deprecate it! - + should be used in the assignment:

maxWindowSize = +arguments[2];

Friendly ping - any progress here?

I'll see what I can do about this this week. We also have a core team meeting this week.

Thanks Ben!

Is it expected that #5124 addresses this?

I think the from part was fixed by TS 3.6.4, and Moshe fixed the Number issue. So this should be complete, except maybe for the node typings.

node typings should also be fixed in the RxJS PR

On Thu, Nov 7, 2019, 4:44 PM Martin Probst notifications@github.com wrote:

I think the from part was fixed by TS 3.6.4, and Moshe fixed the Number
issue. So this should be complete, except maybe for the node typings.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/ReactiveX/rxjs/issues/5047?email_source=notifications&email_token=AAJB6FDV2ZB4RMORUVIUVPTQSSD3DA5CNFSM4I3XWUNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDN5U2Y#issuecomment-551279211,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAJB6FF43XLXDBM5CTH3DLDQSSD3DANCNFSM4I3XWUNA
.

Resolved by #5124

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benlesh picture benlesh  Â·  3Comments

matthewwithanm picture matthewwithanm  Â·  4Comments

chalin picture chalin  Â·  4Comments

dooreelko picture dooreelko  Â·  3Comments

benlesh picture benlesh  Â·  3Comments