Skip to content

Commit

Permalink
update website
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbok committed May 28, 2024
1 parent 3d0cd61 commit 4e54acf
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion website/src/content/docs/book/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The `protected` modifier allows access to the class member within the containing

The `public` modifier provides unrestricted access to the class member, allowing it to be accessed from anywhere."

### Get & Set
### Get and Set

Getters and setters are special methods that allow you to define custom access and modification behavior for class properties. They enable you to encapsulate the internal state of an object and provide additional logic when getting or setting the values of properties.
In TypeScript, getters and setters are defined using the `get` and `set` keywords respectively. Here's an example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ tsc src/*.ts // Compile any .ts files under the 'src' folder to JavaScript
tsc app.ts util.ts --outfile index.js // Compile two TypeScript files (app.ts and util.ts) into a single JavaScript file (index.js)
```

### TypeScript Configuration File ​​tsconfig.json
### TypeScript Configuration File

A tsconfig.json file is used to configure the TypeScript Compiler (tsc). Usually, it is added to the root of the project, together with the `package.json` file.

Expand Down
8 changes: 4 additions & 4 deletions website/src/content/docs/book/others.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async function* asyncNumbers(): AsyncIterableIterator<number> {
})();
```

### New.target
### New target meta-property

You can use in TypeScript the `new.target` meta-property which enables you to determine if a function or constructor was invoked using the new operator. It allows you to detect whether an object was created as a result of a constructor call.

Expand Down Expand Up @@ -354,7 +354,7 @@ tsc --watch

Starting from TypeScript version 4.9, file monitoring primarily relies on file system events, automatically resorting to polling if an event-based watcher cannot be established.

### Non-null Assertion Operator (Postfix !)
### Non-null Assertion Operator

The Non-null Assertion Operator (Postfix !) also called Definite Assignment Assertions is a TypeScript feature that allows you to assert that a variable or property is not null or undefined, even if TypeScript's static type analysis suggests that it might be. With this feature it is possible to remove any explicit checking.

Expand Down Expand Up @@ -401,7 +401,7 @@ const person: Person = {
console.log(person.address?.city); // undefined
```

### Nullish coalescing operator (??)
### Nullish coalescing operator

The nullish coalescing operator `??` returns the right-hand side value if the left-hand side is `null` or `undefined`; otherwise, it returns the left-hand side value.

Expand Down Expand Up @@ -494,7 +494,7 @@ type NestedArray = [1, [2, [3, 4], 5], 6];
type FlattenedArray = Flatten<NestedArray>; // 2 | 3 | 4 | 5 | 1 | 6
```

### ECMAScript Module Support in Node.js
### ECMAScript Module Support in Node

Node.js added support for ECMAScript Modules starting from version 15.3.0, and TypeScript has had ECMAScript Module Support for Node.js since version 4.7. This support can be enabled by using the `module` property with the value `nodenext` in the tsconfig.json file. Here's an example:

Expand Down
13 changes: 7 additions & 6 deletions website/src/content/docs/book/table-of-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sidebar:
- Getting Started With TypeScript
- Installation
- Configuration
- TypeScript Configuration File ​​tsconfig.json
- TypeScript Configuration File
- target
- lib
- strict
Expand Down Expand Up @@ -132,7 +132,7 @@ sidebar:
- Constructor
- Private and Protected Constructors
- Access Modifiers
- Get \& Set
- Get and Set
- Auto-Accessors in Classes
- this
- Parameter Properties
Expand Down Expand Up @@ -193,18 +193,18 @@ sidebar:
- ES6 Modules
- ES7 Exponentiation Operator
- The for-await-of Statement
- New.target
- New target meta-property
- Dynamic Import Expressions
- "tsc –watch"
- Non-null Assertion Operator (Postfix !)
- Non-null Assertion Operator
- Defaulted declarations
- Optional Chaining
- Nullish coalescing operator (??)
- Nullish coalescing operator
- Template Literal Types
- Function overloading
- Recursive Types
- Recursive Conditional Types
- ECMAScript Module Support in Node.js
- ECMAScript Module Support in Node
- Assertion Functions
- Variadic Tuple Types
- Boxed types
Expand All @@ -216,3 +216,4 @@ sidebar:
- using declaration and Explicit Resource Management
- await using declaration
<!-- markdownlint-enable MD004 -->

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ tsc src/*.ts // 将 'src' 文件夹下任意的 .ts 文件编译成 JavaScript
tsc app.ts util.ts --outfile index.js // 将 2 个 TypeScript 文件 (app.ts 和 util.ts) 编译成 1 个 JavaScript 文件 (index.js)
```

### TypeScript 的配置文件 tsconfig.json
### TypeScript 的配置文件

tsconfig.json 文件用于配置 TypeScript 编译器 (tsc)。通常,它与文件一起添加到项目的根目录中package.json。

Expand Down Expand Up @@ -143,6 +143,7 @@ TypeScript 可以为各种模块系统生成代码,包括 UMD、System、ESNex
<!-- markdownlint-disable MD049 -->
"include"属性向编译器指示我们想要包含的文件列表。此属性允许类似 glob 的模式,例如 "\*_" 表示任何子目录,"_" 表示任何文件名,"?" 表示可选字符。
<!-- markdownlint-enable MD049 -->

#### exclude

"exclude"属性向编译器指示不应包含在编译中的文件列表。这可以包括"node_modules"等文件或测试文件
Expand Down
6 changes: 3 additions & 3 deletions website/src/content/docs/zh-cn/book/others.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async function* asyncNumbers(): AsyncIterableIterator<number> {
})();
```

### New.target
### New target 元属性

您可以在 TypeScript 中使用 `new.target` 元属性,该属性使您能够确定是否使用 new 运算符调用函数或构造函数。它允许您检测对象是否是由于构造函数调用而创建的。

Expand Down Expand Up @@ -385,7 +385,7 @@ const person: Person = {
console.log(person.address?.city); // undefined
```

### 空合并运算符 (??)
### 空合并运算符

如果 `??` 左侧是 `null` 或者 `undefined` ,则空合并运算符返回右侧值,否则,它返回左侧值。

Expand Down Expand Up @@ -476,7 +476,7 @@ type NestedArray = [1, [2, [3, 4], 5], 6];
type FlattenedArray = Flatten<NestedArray>; // 2 | 3 | 4 | 5 | 1 | 6
```

### Node.js 中的 ECMAScript 模块支持
### Node 中的 ECMAScript 模块支持

Node.js 从 15.3.0 版本开始添加了对 ECMAScript 模块的支持,而 TypeScript 从 4.7 版本开始增加了对 Node.js 的 ECMAScript 模块支持。可以通过将 `tsconfig.json` 文件中的`module`属性的值设置为 `nodenext` 来启用此支持。这是一个例子:

Expand Down
8 changes: 4 additions & 4 deletions website/src/content/docs/zh-cn/book/table-of-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sidebar:
- TypeScript 入门
- 安装
- 配置
- TypeScript 的配置文件 tsconfig.json
- TypeScript 的配置文件
- target
- lib
- strict
Expand Down Expand Up @@ -194,17 +194,17 @@ sidebar:
- ES6 模块
- ES7 求幂运算符
- for-await-of 语句
- New.target
- New target 元属性
- 动态导入表达式
- "tsc –watch"
- 默认声明
- 可选链
- 空合并运算符 (??)
- 空合并运算符
- 模板字符串类型
- 函数重载
- 递归类型
- 递归条件类型
- Node.js 中的 ECMAScript 模块支持
- Node 中的 ECMAScript 模块支持
- 断言函数
- 可变参数元组类型
- 装箱类型
Expand Down

0 comments on commit 4e54acf

Please sign in to comment.