Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: combineLatest POJO signature should match only ObservableInput values #6103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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