使用 CLI
在本地运行 tsc 将编译由 tsconfig.json 定义的最接近的项目,您可以通过传入一个您想要的文件来编译一组 TypeScript 文件。
Running tsc locally will compile the closest project defined by a tsconfig.json, you can compile a set of TypeScript files by passing in a glob of files you want.
## Run a compile based on a backwards look through the fs for a tsconfig.json
tsc
## Emit JS for just the index.ts with the compiler defaults
tsc index.ts
## Emit JS for any .ts files in the folder src, with the default settings
tsc src/*.ts
## Emit files referenced in with the compiler settings from tsconfig.production.json
tsc --project tsconfig.production.json
## Emit d.ts files for a js file with showing compiler options which are booleans
tsc index.js --declaration --emitDeclarationOnly
## Emit a single .js file from two files via compiler options which take string arguments
tsc app.ts util.ts --target esnext --outfile index.js