1First check if your file has a "tsx" extension or not, if not add it .
2//(First way)
3npm install @types/react@latest --save-dev
4
5//(Second way)
6npm i @types/react@latest --save
7delete node_modules
8delete yarn.lock
9then run
10npm install or (yarn install)