From 242b09f5e37b5a7fd6b791d428af8abc890950bc Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 24 Aug 2021 11:09:21 -0400 Subject: [PATCH] Add types for Observable.{call,apply}. We implemented these methods explicitly in PR #1, but then PR #105 went back to compiling `Observable` down to ES5 constructor functions. In other words, the current implementations of `Observable` (both CommonJS and ESM) automatically have these static methods, and they work just like `Function.prototype.{call,apply}`, because `Observable` is compiled in both cases from a `class` to a constructor function. --- index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.d.ts b/index.d.ts index b889305..c06c4d2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -29,6 +29,12 @@ interface ObservableLike { export declare class Observable { constructor(subscriber: Subscriber); + // For backwards compatibility when super(subscriber) is transpiled to + // Observable.call(this, subscriber), which typically happens when the + // Observable class is compiled to ES5 function contructor syntax. + static call(instance: Observable, subscriber: Subscriber): undefined; + static apply(instance: Observable, args: IArguments | [Subscriber]): undefined; + subscribe(observer: Observer): Subscription; subscribe( onNext: (value: T) => void,