We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0299aa9 commit 84474dbCopy full SHA for 84474db
docs/module.md
@@ -84,17 +84,19 @@ import { type A, a } from './a';
84
85
上面示例中,import 语句输入的类型`A`前面有`type`关键字,表示这是一个类型。
86
87
-第二个方法是使用 import type 语句,这个语句只能输入类型,不能输入正常接口。
+第二个方法是使用 import type 语句,这个语句只用来输入类型,不用来输入正常接口。
88
89
```typescript
90
// 正确
91
import type { A } from './a';
92
+let b:A = 'hello';
93
94
// 报错
95
import type { a } from './a';
96
+let b = a;
97
```
98
-上面示例中,import type 输入类型`A`是正确的,但是输入正常接口`a`就会报错。
99
+上面示例中,import type 输入类型`A`是正确的,可以把`A`当作类型使用。但是,输入正常接口`a`,并把`a`当作一个值使用,就会报错。这就是说,看到`import type`,你就知道它输入的肯定是类型。
100
101
import type 语句也可以输入默认类型。
102
0 commit comments