I'm just beginning to explore TypeScript and I ran into an issue while trying to type my constant dialogFuncMap
. I received an error (listed in the comments below). Why am I getting this error if the type of state is boolean
? And how can I resolve it without using "any"?
state:
const [displayBasic, setDisplayBasic] = useState<boolean>(false);
function:
const dialogFuncMap: Record<string, boolean> = {
'displayBasic': setDisplayBasic, // TS2322: Type 'Dispatch<SetStateAction<boolean>>' is not assignable to type 'boolean'.
}