来自事件的Rxjs:类型'MonoTypeOperatorFunction <Model>'的参数不能分配给'OperatorFunction <unknown,Model>类型的参数

时间:2020-06-09 12:56:40

标签: typescript rxjs rxjs-pipeable-operators

我有一个套接字服务,我试图使用Rxjs fromEvent从套接字中仅获取1个事件。

代码:

   onInitialModels(): Observable<Model> {
        return fromEvent(this.socket, 'models').pipe(take(1));
      }

错误:

 Argument of type 'MonoTypeOperatorFunction<Model>' is not assignable to parameter of type 'OperatorFunction<unknown, Model>

如果我将“ any”(而不是模型)设置为

,则以上代码运行良好

模型是一个简单的类/接口

可以使用吗?

0 个答案:

没有答案