Reactive-Extensions / RxJS

The Reactive Extensions for JavaScript
http://reactivex.io
Other
19.48k stars 2.1k forks source link

Better typings for Observable.d.ts: create #1376

Open donaldpipowitch opened 7 years ago

donaldpipowitch commented 7 years ago

I can't really find the source code for this, but in the distributed package the Observable.d.ts could have a better definition for create. Currently it looks like this:

    /**
     * Creates a new cold Observable by calling the Observable constructor
     * @static true
     * @owner Observable
     * @method create
     * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
     * @return {Observable} a new cold observable
     */
    static create: Function;

Using it can throw an error, if you don't want implicit any's. I guess something like that would be better:

    /**
     * Creates a new cold Observable by calling the Observable constructor
     * @static true
     * @owner Observable
     * @method create
     * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
     * @return {Observable} a new cold observable
     */
    static create<T>(subscribe?: <R>(this: Observable<T>, subscriber: Subscriber<R>) => TeardownLogic): Observable<T>;