I just stumbled upon the fact that TypeScript is not quite strict control over the assignment of functions: https://www.typescriptlang.org/docs/handbook/type-compatibility.html#function-parameter-bivariance
Unfortunately, for some templates, the bivariance parameter skips important type checking. So I'm wondering if it's possible to create my own TSLint rule telling me when I do something like this:
interface Base {}
interface BaseEx extends Base { x; }
let fn1: (a: Base) => void;
let fn2: (b: BaseEx) => void;
fn1 = fn2;
However, the documentation for creating TSLint custom rules seems rather incomplete, I found only one example of a purely syntax check. I would be very happy if you could advise me on a resource to learn how to extend TSLint with semantic rules like this.
bloxx source
share