Skip to content

Commit 84474db

Browse files
committed
docs(module): fixed wangdoc#96
1 parent 0299aa9 commit 84474db

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/module.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,19 @@ import { type A, a } from './a';
8484

8585
上面示例中,import 语句输入的类型`A`前面有`type`关键字,表示这是一个类型。
8686

87-
第二个方法是使用 import type 语句,这个语句只能输入类型,不能输入正常接口
87+
第二个方法是使用 import type 语句,这个语句只用来输入类型,不用来输入正常接口
8888

8989
```typescript
9090
// 正确
9191
import type { A } from './a';
92+
let b:A = 'hello';
9293

9394
// 报错
9495
import type { a } from './a';
96+
let b = a;
9597
```
9698

97-
上面示例中,import type 输入类型`A`是正确的,但是输入正常接口`a`就会报错。
99+
上面示例中,import type 输入类型`A`是正确的,可以把`A`当作类型使用。但是,输入正常接口`a`,并把`a`当作一个值使用,就会报错。这就是说,看到`import type`,你就知道它输入的肯定是类型
98100

99101
import type 语句也可以输入默认类型。
100102

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy