Open this example in the interactive library
Source code
type ElementOf<T> = T extends readonly (infer U)[] ? U : never;
console.log(
(() => {
type First<T> = T extends (arg: infer A) => unknown ? A : never;
const value: First<(s: string) => void> = "ok";
return value;
})(),
);
Sample output
ok
