完整的 TypeScript 迁移,提升代码质量和开发体验 **安装依赖:** - TypeScript 5.9.3 - @types/react, @types/react-dom, @types/node - typescript-eslint 相关包 **配置文件:** - 创建 tsconfig.json (应用配置) - 创建 tsconfig.node.json (Node 配置) - 更新 eslint.config.ts 支持 TypeScript - 所有配置文件迁移到 .ts 扩展名 **源代码迁移:** - 所有 .jsx 文件 → .tsx - 所有 .js 文件 → .ts - 添加完整的类型定义和接口 - 修复所有类型错误 **类型定义:** - Experiment 接口 (实验数据类型) - DraggableItemProps 接口 - 函数参数类型注解 - React 组件 Props 类型 **代码优化:** - 修复 main.tsx 中的 null 检查 - 添加 DragEndEvent 类型 - 使用类型守卫和类型断言 - 改进错误处理 **构建脚本:** - 添加 typecheck 脚本 - build 脚本包含类型检查 - 更新 index.html 入口为 main.tsx **验证:** - ✅ TypeScript 编译通过 - ✅ ESLint 检查通过 - ✅ 所有类型正确推导 - ✅ 代码质量提升 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
1.3 KiB
JSON
50 lines
1.3 KiB
JSON
{
|
|
"name": "sensor-lab",
|
|
"private": true,
|
|
"version": "0.0.0",
|
|
"type": "module",
|
|
"packageManager": "pnpm@10.18.3",
|
|
"engines": {
|
|
"node": ">=18.0.0",
|
|
"pnpm": ">=10.0.0"
|
|
},
|
|
"scripts": {
|
|
"dev": "vite",
|
|
"build": "tsc && vite build",
|
|
"lint": "eslint .",
|
|
"typecheck": "tsc --noEmit",
|
|
"preview": "vite preview"
|
|
},
|
|
"dependencies": {
|
|
"@dnd-kit/core": "^6.3.1",
|
|
"@dnd-kit/sortable": "^10.0.0",
|
|
"@dnd-kit/utilities": "^3.2.2",
|
|
"axios": "^1.12.2",
|
|
"clsx": "^2.1.1",
|
|
"lucide-react": "^0.545.0",
|
|
"react": "^19.1.1",
|
|
"react-dom": "^19.1.1",
|
|
"react-router-dom": "^7.9.4"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^9.36.0",
|
|
"@tailwindcss/postcss": "^4.1.14",
|
|
"@types/node": "^24.8.0",
|
|
"@types/react": "^19.1.16",
|
|
"@types/react-dom": "^19.1.9",
|
|
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
|
"@typescript-eslint/parser": "^8.46.1",
|
|
"@vitejs/plugin-react": "^5.0.4",
|
|
"autoprefixer": "^10.4.21",
|
|
"eslint": "^9.36.0",
|
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
"eslint-plugin-react-refresh": "^0.4.22",
|
|
"globals": "^16.4.0",
|
|
"postcss": "^8.5.6",
|
|
"tailwindcss": "^4.1.14",
|
|
"typescript": "^5.9.3",
|
|
"typescript-eslint": "^8.46.1",
|
|
"vite": "^7.1.7"
|
|
}
|
|
}
|