I'm trying to better understand using infer keyword in typescript.
Would this be a valid demonstration on using infer properly ?
I want to just infer the return type of the following function,
const [name, setName] = useState<string>('');
const [age, setAge] = useState<number>();
type CallbackType<T> = T extends () => infer R ? R: never
function stateCallback<T>(name: string, age: number): CallbackType<T>{
setName(name)
setAge(age);
}
It should return a void type as im not returning anything, is this the right approach on using infer ?