mirror of
https://github.com/wangdoc/typescript-tutorial.git
synced 2025-12-20 00:50:17 +08:00
docs(declare): fixed #91
This commit is contained in:
@@ -296,13 +296,13 @@ String.prototype.toSmallString = ():string => {
|
||||
|
||||
这个示例第一行的空导出语句`export {}`,作用是强制编译器将这个脚本当作模块处理。这是因为`declare global`必须用在模块里面。
|
||||
|
||||
下面的示例是为 window 对象添加一个属性`myAppConfig`。
|
||||
下面的示例是为 window 对象(类型接口为`Window`)添加一个属性`myAppConfig`。
|
||||
|
||||
```typescript
|
||||
export {};
|
||||
|
||||
declare global {
|
||||
interface window {
|
||||
interface Window {
|
||||
myAppConfig:object;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user