4

I have the following code which compiled without errors in rxjs 5:

a$ = Observable.combineLatest([x$, y$])
  .subscribe(([x, y]:[X, Y]) => {

When I update to rxjs 6 the following error occurs:

Argument of type '([x, y]: [X, Y]) => void' is not assignable to parameter of type '(value: Y[]) => void'.
  Types of parameters '__0' and 'value' are incompatible.
Type 'Y[]' is not assignable to type '[X, Y]'.
  Property '0' is missing in type 'Y[]'.

Also, the error goes away if I change either type X or Y to the any type.

okhobb
  • 758
  • 8
  • 22
  • 1
    AFAICT, if you pass an array to `combineLatest` it's treated as an `ObservableInput`, so an error is appropriate. Try `Observable.combineLatest(...[x$, y$]))` - but the type inference will depend upon your TypeScript version. – cartant Nov 12 '18 at 23:10
  • 2
    Thanks for noting that it was an array. Your suggestion seems to have the same error but changing it to `Observable.combineLatest(x$, y$)` solved the error. – okhobb Nov 12 '18 at 23:21
  • Yeah, the array is unnecessary. – cartant Nov 12 '18 at 23:22
  • Indeed I was updating from TypeScript 2 to 3 at the same time so perhaps the rxjs version was red herring here. – okhobb Nov 12 '18 at 23:42

0 Answers0