Skip to content

Commit ae9bea9

Browse files
committedMay 23, 2024·
docs(declare): 修改不能单独写函数类型声明的示例
1 parent 57cdc82 commit ae9bea9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

Diff for: ‎docs/declare.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ declare function sayHello(
8282
sayHello('张三');
8383
```
8484

85-
上面示例中,declare 命令给出了`sayHello()`的类型描述,因此可以直接使用它
85+
上面示例中,declare 命令给出了`sayHello()`的类型描述,表示这个函数是由外部文件定义的,因此这里可以直接使用该函数
8686

8787
注意,这种单独的函数类型声明语句,只能用于`declare`命令后面。一方面,TypeScript 不支持单独的函数类型声明语句;另一方面,declare 关键字后面也不能带有函数的具体实现。
8888

@@ -91,7 +91,10 @@ sayHello('张三');
9191
function sayHello(
9292
name:string
9393
):void;
94-
function sayHello(name) {
94+
95+
let foo = 'bar';
96+
97+
function sayHello(name:string) {
9598
return '你好,' + name;
9699
}
97100
```

0 commit comments

Comments
 (0)
Please sign in to comment.