Mohamed Keita
Mohamed Keita

Reputation: 21

after update to 6.3.3 I get in pipe() error TS2557: Expected at least 0 arguments, but got 1 or more.

Please someone can help,

in rxjs 6.3.3 pipe get TS2557: Expected at least 0 arguments, but got 1 or more.

   let currentPath;
const pipeArguments = path
  .map((subPath: string, index: number) => [
    flatMap((href: string) => {
      console.log('href', href);
      return this.getEndpointMapAt(href);
    }),
    map((endpointMap: EndpointMap) => {
      console.log('map', endpointMap);
      if (hasValue(endpointMap) && hasValue(endpointMap[subPath])) {
        currentPath = endpointMap[subPath];
        return endpointMap[subPath];
      } else {
        currentPath += '/' + subPath;
        return currentPath;
      }
    })
  ])
  .reduce((combined, thisElement) => [...combined, ...thisElement], []);
return of(this.getRootHref()).pipe(
  ...pipeArguments,
  distinctUntilChanged()
);

Upvotes: 1

Views: 930

Answers (2)

André Werlang
André Werlang

Reputation: 5964

It's a problem with static typing. Casting to any works, but it's a hack.

A type-safe approach is to reduce() over the pipe array:

return pipeArguments
    .reduce((obs, op) => obs.pipe(op), of('http://localhost:8001/1/'))
    .pipe(distinctUntilChanged()

Reference:

Upvotes: 0

Mohamed Keita
Mohamed Keita

Reputation: 21

Until the code linked to that issue is merged, I think you're stuck with the same as any hack seen here, so: here

and issue

return (of('http://localhost:8001/1/') as any).pipe(
 ...pipeArguments,
 distinctUntilChanged()
);

Upvotes: 1

Related Questions