diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 790225fea5..e79c865185 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -43,7 +43,9 @@ export declare function bindNodeCallback; export declare function combineLatest(sources: readonly [...ObservableInputTuple]): Observable; export declare function combineLatest(...sources: [...ObservableInputTuple]): Observable; -export declare function combineLatest(sourcesObject: {}): Observable; +export declare function combineLatest(sourcesObject: { + [K in any]: never; +}): Observable; export declare function combineLatest(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf; }>; @@ -166,7 +168,9 @@ export declare function firstValueFrom(source: Observable): Promise; export declare function forkJoin(sources: []): Observable; export declare function forkJoin(sources: readonly [...ObservableInputTuple]): Observable; export declare function forkJoin(...sources: [...ObservableInputTuple]): Observable; -export declare function forkJoin(sourcesObject: {}): Observable; +export declare function forkJoin(sourcesObject: { + [K in any]: never; +}): Observable; export declare function forkJoin(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf; }>; diff --git a/spec-dtslint/observables/combineLatest-spec.ts b/spec-dtslint/observables/combineLatest-spec.ts index 3958368bc2..679c43dbcc 100644 --- a/spec-dtslint/observables/combineLatest-spec.ts +++ b/spec-dtslint/observables/combineLatest-spec.ts @@ -136,4 +136,9 @@ describe('combineLatest({})', () => { it('should work for the simple case', () => { const res = combineLatest({ foo: a$, bar: b$, baz: c$ }); // $ExpectType Observable<{ foo: A; bar: B; baz: C; }> }); + + it('should not rely upon the excess-properties behavior to identify empty objects', () => { + const obj = { foo: a$, bar: b$, baz: c$ }; + const res = combineLatest(obj); // $ExpectType Observable<{ foo: A; bar: B; baz: C; }> + }); }); diff --git a/spec-dtslint/observables/forkJoin-spec.ts b/spec-dtslint/observables/forkJoin-spec.ts index 91f48cb5a5..84242ae3a8 100644 --- a/spec-dtslint/observables/forkJoin-spec.ts +++ b/spec-dtslint/observables/forkJoin-spec.ts @@ -67,6 +67,11 @@ describe('forkJoin({})', () => { it('should work for the simple case', () => { const res = forkJoin({ foo: of(1), bar: of('two'), baz: of(false) }); // $ExpectType Observable<{ foo: number; bar: string; baz: boolean; }> }); + + it('should not rely upon the excess-properties behavior to identify empty objects', () => { + const obj = { foo: of(1), bar: of('two'), baz: of(false) }; + const res = forkJoin(obj); // $ExpectType Observable<{ foo: number; bar: string; baz: boolean; }> + }); }); describe('forkJoin([])', () => { diff --git a/src/internal/observable/combineLatest.ts b/src/internal/observable/combineLatest.ts index fe16b9509d..1dff5ec607 100644 --- a/src/internal/observable/combineLatest.ts +++ b/src/internal/observable/combineLatest.ts @@ -18,7 +18,7 @@ export function combineLatest(sources: readonly [. export function combineLatest(...sources: [...ObservableInputTuple]): Observable; // combineLatest({a, b, c}) -export function combineLatest(sourcesObject: {}): Observable; +export function combineLatest(sourcesObject: { [K in any]: never }): Observable; export function combineLatest(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf }>; // If called with a single array, it "auto-spreads" the array, with result selector diff --git a/src/internal/observable/forkJoin.ts b/src/internal/observable/forkJoin.ts index 97b8c769bb..9bc1454dfa 100644 --- a/src/internal/observable/forkJoin.ts +++ b/src/internal/observable/forkJoin.ts @@ -15,12 +15,11 @@ export function forkJoin(sources: readonly [...Obs export function forkJoin(...sources: [...ObservableInputTuple]): Observable; // forkJoin({a, b, c}) -export function forkJoin(sourcesObject: {}): Observable; +export function forkJoin(sourcesObject: { [K in any]: never }): Observable; export function forkJoin(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf }>; // forkJoin(a, b, c, resultSelector) /** @deprecated resultSelector is deprecated, pipe to map instead */ - export function forkJoin(...args: Array | ((...args: any[]) => any)>): Observable; /**