In the following, imho, at least the error message indicates TS is incorrectly using an intersection for member access with a union:
type O = { i: [string]; j: [boolean] };
type HOF = <U extends keyof O>(a: (...args: O[U]) => void) => void;
const f: HOF = (a: (...args: any[]) => void) => {};
I can't understand a step in the error (numbering mine):
1: Type '(a: (...args: any[]) => {}) => void' is not assignable to type 'HOF'.
2: Types of parameters 'a' and 'a' are incompatible.
3: Types of parameters 'args' and 'args' are incompatible.
4: Type 'any[]' is not assignable to type 'O[U]'.
5: Type 'any[]' is not assignable to type 'never'.
6: The intersection '[string] & [boolean]' was reduced to 'never' because property '0' has conflicting types in some constituents.(2322)
How did we get from (4) O[U]
to (6) [string] & [boolean]
?