Skip to content

Commit

Permalink
fix: combineLatest POJO signature should match only ObservableInput v…
Browse files Browse the repository at this point in the history
…alues (#6103)

* test: add failing POJO test

* fix: tighten combineLatest POJO signature

* chore: update api_guardian

* chore: tighten Record type

* chore: update api_guardian
  • Loading branch information
cartant authored Mar 10, 2021
1 parent 13db11f commit d633494
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api_guard/dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export declare function combineLatest<A extends readonly unknown[]>(...args: [..
export declare function combineLatest(sourcesObject: {
[K in any]: never;
}): Observable<never>;
export declare function combineLatest<T>(sourcesObject: T): Observable<{
export declare function combineLatest<T extends Record<string, ObservableInput<any>>>(sourcesObject: T): Observable<{
[K in keyof T]: ObservedValueOf<T[K]>;
}>;
export declare function combineLatest<O extends ObservableInput<any>, R>(array: O[], resultSelector: (...values: ObservedValueOf<O>[]) => R, scheduler?: SchedulerLike): Observable<R>;
Expand Down
5 changes: 5 additions & 0 deletions spec-dtslint/observables/combineLatest-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,9 @@ describe('combineLatest({})', () => {
const obj = { foo: a$, bar: b$, baz: c$ };
const res = combineLatest(obj); // $ExpectType Observable<{ foo: A; bar: B; baz: C; }>
});

it('should reject non-ObservableInput values', () => {
const obj = { answer: 42 };
const res = combineLatest(obj); // $ExpectError
});
});
4 changes: 3 additions & 1 deletion src/internal/observable/combineLatest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export function combineLatest<A extends readonly unknown[]>(...args: [...Observa

// combineLatest({a, b, c})
export function combineLatest(sourcesObject: { [K in any]: never }): Observable<never>;
export function combineLatest<T>(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;
export function combineLatest<T extends Record<string, ObservableInput<any>>>(
sourcesObject: T
): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;

/** @deprecated resultSelector no longer supported, pipe to map instead */
export function combineLatest<O extends ObservableInput<any>, R>(
Expand Down

0 comments on commit d633494

Please sign in to comment.