- 下载
npm install typescript --save-dev
npm install @types/react @types/react-dom
- 添加 ts.config.json 文件
如果原来有 js.config.json 文件把原有的 js.config.json 内容迁移到 ts.config.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"experimentalDecorators": true,
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
],
"components/*": [
"src/components/*"
],
"assets/*": [
"src/assets/*"
],
"views/*": [
"src/views/*"
],
"common/*": [
"src/common/*"
],
"@business/*": [
"src/pages/designer/workspace/business/*"
]
}
},
"include": [
"src"
],
"exclude": [
"node_modules",
"dist"
]
}
- 重启项目