代码之家  ›  专栏  ›  技术社区  ›  Pallavi

类型“observate<[{},{}]>上不存在属性“map”

  •  0
  • Pallavi  · 技术社区  · 7 年前

    我试过了

    导入映射,安装rxjs compat,编辑tsconfig.json

      unifiedSearch: Function = (query: string): Observable<UnifiedSearch> => {
        return forkJoin(
          this.searchService.gitSearch(query),
          this.codeSearchService.codeSearch(query)
        ).map((response :[GitSearch,GitCodeSearch])=> {
          return {
            respositories: response[0],
            code: response[1]
          };
        });
      };
    

    如果我想用“管道”来实现它,它会说我找不到地图。

     unifiedSearch: Function = (query: string): Observable<UnifiedSearch> => {
        return forkJoin(
          this.searchService.gitSearch(query),
          this.codeSearchService.codeSearch(query)
        ).pipe(map((response :[GitSearch,GitCodeSearch])=> {
          return {
            respositories: response[0],
            code: response[1]
          };
        }));
      };
    

    Error while implementing maps

    1 回复  |  直到 7 年前
        1
  •  0
  •   toothful    7 年前

    一定要像这样导入地图-

    import { map } from 'rxjs/operators';
    

    也要用管子。