Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0d51628

Browse files
committedAug 1, 2023
docs: finish chapter tsc
1 parent e05a44b commit 0d51628

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed
 

‎docs/tsc.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44

55
tsc 是 TypeScript 官方的命令行编译器,用来检查代码,并将其编译成 JavaScript 代码。
66

7-
tsc 默认使用当前目录下的配置文件`tsconfig.json`,但也可以接受独立的命令行参数。
7+
tsc 默认使用当前目录下的配置文件`tsconfig.json`,但也可以接受独立的命令行参数。命令行参数会覆盖`tsconfig.json`,比如命令行指定了所要编译的文件,那么 tsc 就会忽略`tsconfig.json``files`属性。
88

9-
如果命令行指定了所要编译的文件,那么 tsc 会忽略`tsconfig.json``files`属性。
10-
11-
它的基本用法如下。
9+
tsc 的基本用法如下。
1210

1311
```bash
14-
# 按照 tsconfig.json 编译
12+
# 使用 tsconfig.json 的配置
1513
$ tsc
1614

17-
# 只编译 index.ts
15+
# 只编译 index.ts
1816
$ tsc index.ts
1917

2018
# 编译 src 目录的所有 .ts 文件
@@ -23,7 +21,7 @@ $ tsc src/*.ts
2321
# 指定编译配置文件
2422
$ tsc --project tsconfig.production.json
2523

26-
# 只类型生明文件,不编译出 JS 文件
24+
# 只生成类型声明文件,不编译出 JS 文件
2725
$ tsc index.js --declaration --emitDeclarationOnly
2826

2927
# 多个 TS 文件编译成单个 JS 文件
@@ -34,7 +32,7 @@ $ tsc app.ts util.ts --target esnext --outfile index.js
3432

3533
tsc 的命令行参数,大部分与 tsconfig.json 的属性一一对应。
3634

37-
下面只是简单罗列主要的一些参数,详细解释可以参考《tsconfig.json 配置文件》一章。
35+
下面只是按照首字母排序,简单罗列出主要的一些参数,详细解释可以参考《tsconfig.json 配置文件》一章。
3836

3937
`--all`:输出所有可用的参数。
4038

@@ -46,15 +44,15 @@ tsc 的命令行参数,大部分与 tsconfig.json 的属性一一对应。
4644

4745
`--alwaysStrict`:总是在编译产物的头部添加`use strict`
4846

49-
`--baseUrl`指定非相对的模块的基准 URL。
47+
`--baseUrl`指定非相对位置的模块定位的基准 URL。
5048

5149
`--build`:启用增量编译。
5250

5351
`--checkJs`:对 JS 脚本进行类型检查。
5452

5553
`--declaration`:为 TS 脚本生成一个类型生成文件。
5654

57-
`--declarationDir`指定生成的类型声明文件的目录
55+
`--declarationDir`指定生成的类型声明文件的所在目录
5856

5957
`--declarationMap`:为`.d.ts`文件生成 SourceMap 文件。
6058

@@ -180,8 +178,9 @@ tsc 的命令行参数,大部分与 tsconfig.json 的属性一一对应。
180178

181179
`--typeRoots`:设置类型模块所在的目录,替代默认的`node_modules/@types`
182180

183-
`--types`:设置`node_modules/@types`目录下需要包括在编译之中的类型模块。
181+
`--types`:设置`typeRoots`目录下需要包括在编译之中的类型模块。
184182

185183
`--version`:终端输出 tsc 的版本号。
186184

187185
`--watch`(或者`-w`):进入观察模式,只要文件有修改,就会自动重新编译。
186+

0 commit comments

Comments
 (0)
Please sign in to comment.