I was going through react typescript cheatsheet and one code snippet caught my attention:
export function createCtx<A>(defaultValue: A) {
 type UpdateType = Dispatch<SetStateAction<typeof defaultValue>>;
 const defaultUpdate: UpdateType = () => defaultValue;
 const ctx = createContext({
   state: defaultValue,
   update: defaultUpdate,
 });
 function Provider(props: PropsWithChildren<{}>) {
   const [state, update] = useState(defaultValue);
   return <ctx.Provider value={{ state, update }} {...props} />;
 }
 return [ctx, Provider] as const; // alternatively, [typeof ctx, typeof Provider]
}
the purpose of this function function is to create a context and provider based on the defaultValue passed to the function.
I have difficulty understanding the first two lines of the function:
 type UpdateType = Dispatch<SetStateAction<typeof defaultValue>>;
 const defaultUpdate: UpdateType = () => defaultValue;
Dispatch is defined as:
type Dispatch<A> = (value: A) => void;
and SetStateAction as:
type SetStateAction<S> = S | ((prevState: S) => S);
this make () => defaultValue not assignable to type UpdateType, How this can possible.