带有 Rx 的 Typescript - count() 函数未找到异常

Typescript with Rx - count() function not found exception

我正在使用 Typescript,使用 Reactive 编写 Angular2 应用程序。我不确定为什么,但是当我尝试在 Rx 可观察对象上调用 .count() 时,我得到了异常 'count is not a function'。智能感知显示 .count() 是一个函数,查看 Rx 源代码,我看到了函数。下面是一些抛出异常的代码:

myFunction(): void {
        console.log('made it');
        var x: Rx.Subject<number> = new Rx.Subject<number>();
        //var t = x.count();  //throws here
        var y = x.asObservable();
        var source = y.count(); //throws here
    }

TypeError: y.count is not a function

如果你尝试

会发生什么
var t = (<any>x).count();

?

我的猜测是 TypeScript definition files for Reactive (v2.5.3) lack behind official distribution (v4.0.6).