File size: 1,708 Bytes
100a6dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
echo "Fixing React TypeScript issues..."

# Create a temporary package.json backup
cp package.json package.json.bak

# Remove React and its types
npm uninstall react react-dom @types/react @types/react-dom

# Clean npm cache
npm cache clean --force

# Install React and its types with specific versions known to work well together
npm install --save react@18.2.0 react-dom@18.2.0
npm install --save-dev @types/react@18.2.0 @types/react-dom@18.2.0

# Create a proper tsconfig.json if it doesn't exist
cat > tsconfig.json << EOL
{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "types": ["vite/client", "node"]
  },
  "include": ["src", "**/*.ts", "**/*.tsx", "src/types/*.d.ts"],
  "references": [{ "path": "./tsconfig.node.json" }]
}
EOL

# Create a proper tsconfig.node.json if it doesn't exist
cat > tsconfig.node.json << EOL
{
  "compilerOptions": {
    "composite": true,
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true
  },
  "include": ["vite.config.ts"]
}
EOL

echo "React TypeScript issues fixed! Please restart your IDE or TypeScript server."
echo "You can now run 'npm run dev' to start the development server."