You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[combineLatest] loses the tuple shape of array-literal sources, unlike [forkJoin] #7637
For a: Observable<number> and b: Observable<string>, Observable[combineLatest]([a, b]) returns Observable<(string | number)[]>. Destructured values cannot be assigned to number and string variables.
Observable[forkJoin]([a, b]) returns Observable<[number, string]> and the same assignments compile.
Expected behavior
Save the following as repro.ts in an empty directory, then run:
import"rxjs"import{combineLatest}from"rxjs/combine-latest"import{forkJoin}from"rxjs/fork-join"declareconsta: Observable<number>declareconstb: Observable<string>exportconstcl=Observable[combineLatest]([a,b])exportconstfj=Observable[forkJoin]([a,b])cl.subscribe(([n,s])=>{constx: number=n;consty: string=s})// errorsfj.subscribe(([n,s])=>{constx: number=n;consty: string=s})// ok
Relevant declaration output and diagnostics:
export declare const cl: Observable<(string | number)[]>;
export declare const fj: Observable<[number, string]>;
repro.ts(11,34): error TS2322: Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
repro.ts(11,55): error TS2322: Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
Expected: the result preserves each position's type (number, then string), and both subscriptions compile.
Reproduction code
Reproduction URL
No response
Version
rxjs 9.0.0-beta.0
Environment
TypeScript 6.0.3 with strict. Same result with vue-tsc 3.3.11.
Additional context
Observable[combineLatest]([a, b] as const) returns Observable<readonly [number, string]> and the assignments compile.
Activity