I have the following type, which establishes that all properties are going to be functions, which accept either no arguments, or a single argument of type Record<string, any>:
type FnTrait = Record<
string,
(input?: Record<string, any>) => any
>;
I attempt extend this type into another interface (which I want to have the same constraint).
interface HasFn extends FnTrait {
someFn(): string; // no problem
anotherFn(o: {id: string}): number; // ts error 2411
}
This produces an error on anotherFn: Property 'anotherFn' of type '(o: { id: string; }) => number' is not assignable to string index type '(input?: Record<string | number | symbol, any> | undefined) => any'.
Why is it that someFn produces no error, while anotherFn produces ts error 2411? It seems that this narrowing should be allowed.
Any help would be greatly appreciated. Thank you!