Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update type-of-function.md and primitive-data-types.md #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion basics/primitive-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

JavaScript 的类型分为两种:原始数据类型([Primitive data types][])和对象类型(Object types)。

原始数据类型包括:布尔值、数值、字符串、`null`、`undefined` 以及 ES6 中的新类型 [`Symbol`][] 和 [`BigInt`][]。
原始数据类型包括:布尔值、数值、字符串、`null`、`undefined` 以及 ES6 中的新类型 [`Symbol`][] 和 ES10 中的新类型 [`BigInt`][]。

本节主要介绍**前五种**原始数据类型在 TypeScript 中的应用。

Expand Down
4 changes: 2 additions & 2 deletions basics/type-of-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ push(a, 1, 2, 3);
利用联合类型,我们可以这么实现:

```ts
function reverse(x: number | string): number | string {
function reverse(x: number | string): number | string | void {
if (typeof x === 'number') {
return Number(x.toString().split('').reverse().join(''));
} else if (typeof x === 'string') {
Expand All @@ -200,7 +200,7 @@ function reverse(x: number | string): number | string {
```ts
function reverse(x: number): number;
function reverse(x: string): string;
function reverse(x: number | string): number | string {
function reverse(x: number | string): number | string | void {
if (typeof x === 'number') {
return Number(x.toString().split('').reverse().join(''));
} else if (typeof x === 'string') {
Expand Down