ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
8.01k stars 1.97k forks source link

No usage notes for `tapResponse`, `concatLatestFrom` operators. #4303

Closed tom9744 closed 5 months ago

tom9744 commented 5 months ago

Information

Hi,

I found no usage note displayed for the tapResponse and concatLatestFrom operators in VS Code.

image

image

My application is running on...

Reasoning

This is caused by the JS Docs being mislocated. Comments are supposed to be located right above the function signatures.

Suggestion

Before

export function concatLatestFrom<T extends Observable<unknown>[], V>(
  observablesFactory: (value: V) => [...T]
): OperatorFunction<V, [V, ...{ [i in keyof T]: ObservedValueOf<T[i]> }]>;
export function concatLatestFrom<T extends Observable<unknown>, V>(
  observableFactory: (value: V) => T
): OperatorFunction<V, [V, ObservedValueOf<T>]>;
/**
 * Now the comments are located here.
 */
export function concatLatestFrom<
  T extends ObservableInput<unknown>[] | ObservableInput<unknown>,
  V,
  R = [
    V,
    ...(T extends ObservableInput<unknown>[]
      ? { [i in keyof T]: ObservedValueOf<T[i]> }
      : [ObservedValueOf<T>])
  ]
>(observablesFactory: (value: V) => T): OperatorFunction<V, R> {
  return concatMap((value) => {
    const observables = observablesFactory(value);
    const observablesAsArray = Array.isArray(observables)
      ? observables
      : [observables];
    return of(value).pipe(
      withLatestFrom(...observablesAsArray)
    ) as unknown as Observable<R>;
  });
}

After

/**
 * Now the comments are located here.
 */
export function concatLatestFrom<T extends Observable<unknown>[], V>(
  observablesFactory: (value: V) => [...T]
): OperatorFunction<V, [V, ...{ [i in keyof T]: ObservedValueOf<T[i]> }]>;
export function concatLatestFrom<T extends Observable<unknown>, V>(
  observableFactory: (value: V) => T
): OperatorFunction<V, [V, ObservedValueOf<T>]>;
export function concatLatestFrom<
  T extends ObservableInput<unknown>[] | ObservableInput<unknown>,
  V,
  R = [
    V,
    ...(T extends ObservableInput<unknown>[]
      ? { [i in keyof T]: ObservedValueOf<T[i]> }
      : [ObservedValueOf<T>])
  ]
>(observablesFactory: (value: V) => T): OperatorFunction<V, R> {
  return concatMap((value) => {
    const observables = observablesFactory(value);
    const observablesAsArray = Array.isArray(observables)
      ? observables
      : [observables];
    return of(value).pipe(
      withLatestFrom(...observablesAsArray)
    ) as unknown as Observable<R>;
  });
}

Documentation page

No response

I would be willing to submit a PR to fix this issue

timdeschryver commented 5 months ago

The operators exported from the packages effects and component-store are deprecated (moved to the operators package), and do not have a usage just, just a mention that they are deprecated.

The operators package should have the usage notes implemented.

Also keep in mind that these notes are not visible when you hover over ImportSpecifier nodes, and are only visible on the Identifier nodes.

If the notes are not visible on the latest NgRx version (v17.x), feel free to reopen this issue.