TypeScript – How to fix: Property does not exist on type ‘IntrinsicAttributes & Dispatch’

TypeScript

TypeScript is JavaScript with syntax for types. TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.

How to reproduce it

export function EventOptions(setEventType: React.Dispatch<React.SetStateAction<string>>, eventOptions: React.RefObject<HTMLDivElement>): ReactElement {
...
return <></>;
}

<EventOptions setEventType={setEventType} eventOptions={eventOptions}></EventOptions>

Error

BugFinder: Type '{ setEventType: string; eventOptions: MutableRefObject<HTMLDivElement>; }' is not assignable to type 'IntrinsicAttributes & Dispatch<SetStateAction<string>>'.BugFinder: 
  Property 'setEventType' does not exist on type 'IntrinsicAttributes & Dispatch<SetStateAction<string>>'.

Solution

Update definition of parameters.

export function EventOptions({ setEventType, eventOptions }: { setEventType: React.Dispatch>; eventOptions: React.RefObject }): ReactElement {
…
return <></>;
}
https://www.mldgroup.com

Vyštudovaný top manažér pôsobiaci najmä ako manažér, marketér, softvérový inžinier, konzultant, bloger, YouTuber a zatiaľ neúspešný hudobník a producent. V rámci praxe pôsobil v rôznych odvetviach na rôznych pozíciách v malých aj veľkých firmách, vrátane spoluprác a partnerstiev s významnými firmami či poradenskými spoločnosťami.

Pridaj komentár

Vaša e-mailová adresa nebude zverejnená. Vyžadované polia sú označené *