将ts文件转换为js文件
tsc index.ts
每次修改ts文件后 都重新运行tsc命令将ts转化为js
tsc --watch index.ts
解释: --watch表示启用监视模式,只要重新保存了ts文件 就会自动调用tsc 将ts转化为js
编译给定其配置文件路径的项目
tsc -p ./tsconfig.json
-p : 编译给定其配置文件路径的项目,或使用“tsconfig.json”编译到文件夹的项目
{
"compilerOptions": {
"outDir": "./dist",
"declaration": true, // 设置为 true,表示将会由 ts 文件自动生成 .d.ts 声明文件
"emitDeclarationOnly": true, // 是否只需要生成类型文件
"baseUrl": ".",
"jsx": "preserve",
"strict": true,
"target": "ES2015",
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
"moduleResolution": "Node",
"lib": ["esnext", "dom"]
},
"exclude": [
"node_modules"
],
"include": ["src/**/*"]
}
网友评论