Skip to content

Commit ae9bea9

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/declare.md

Lines changed: 5 additions & 2 deletions
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)
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