I have the following types:
export type SchemaEntry<A extends object, B> =
| Validator<B>
| ((obj: A) => Validator<B>);
export type Schema<A extends object> = { [k in keyof A]: SchemaEntry<A, A[k]> };
And a function that uses them:
function foo<A extends object>(f: Schema<A>): A {
return undefined as any;
}
My issue is that when I call the function:
const a = foo({
b: new Validator<number>(),
c: (o) => new Validator<number>()
});
o's type will in this case be any rather than my expected {b: number, c: number}.
a does however receive the correct type, {b: number, c: number}.
Is there a way that I can help typescript infer the type on my anonymous function?