cartant / rxjs-tslint-rules

TSLint rules for RxJS
https://cartant.github.io/rxjs-tslint-rules/
MIT License
371 stars 22 forks source link

False positive with rxjs-no-subclass #87

Closed timbru31 closed 5 years ago

timbru31 commented 5 years ago

Hi there 👋,

thanks for these rules, really awesome 👍
I'm having a false positive with the rule rxjs-no-subclass. OpenLayers defines Observables, too.
Below is an example snippet which triggers the rule:

declare module 'ol/Object' {
    import Observable from 'ol/Observable';

    // tslint:disable-next-line:rxjs-no-subclass
    class BaseObject extends Observable {
        get(key: string): any;
    }
}

The Observable class is:

declare module 'ol/Observable' {
    export interface GlobalObject { [key: string]: any; }
    export type EventsKey = GlobalObject;

    class Observable {
        constructor();
        changed(): void;
        getRevision(): number;
        on(type: (string | string[]), listener: Function): (EventsKey | EventsKey[]);
        once(type: (string | string[]), listener: Function): (EventsKey | EventsKey[]);
        un(type: (string | string[]), listener: Function): void;
    }

    export default Observable;
}
cartant commented 5 years ago

This should be solvable. However, it will involve digging around in TypeScript's Type representation. And, AFAICT, the documentation is ... the source. I will have a look at this on the weekend. Hopefully, it won't be too much of a challenge.

cartant commented 5 years ago

Should be fixed in 4.18.2.

timbru31 commented 5 years ago

Nice, thanks a lot for the quick fix. I’ll test it later today