I have compilation error when I try the following syntax, but I don't understand why it does not work:
interface Param<O> {
obj: O;
}
interface Dico {
[key: string]: <O>(param: Param<O>) => Param<O>;
}
var x: Dico = {
fnString: (param: Param<string>) => { return param; },
fnNumber: (param: Param<number>) => { return param; }
};
Here is the playground link
Compilation error is on fnString and fnNumber:
Type '(param: Param<string>) => Param<string>' is not assignable to type '<O>(param: Param<O>) => Param<O>'.
Types of parameters 'param' and 'param' are incompatible.
Type 'Param<O>' is not assignable to type 'Param<string>'.
Type 'O' is not assignable to type 'string'.
If I move the generic type O on interface Dico, it works but I cannot use different types like I would like:
What I am missing ? Is this a limitation I can't go around or is there a way to achieve this?

Dicohas values with generic functions accepting differentParam<T>or the latter where all values ofDico<T2>acceptParam<T2>.