Skip to content

Commit

Permalink
docs(interface): fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanyf committed Dec 26, 2023
1 parent 68da0fb commit 0299aa9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ interface Box {

这样的设计主要是为了兼容 JavaScript 的行为。JavaScript 开发者常常对全局对象或者外部库,添加自己的属性和方法。那么,只要使用 interface 给出这些自定义属性和方法的类型,就能自动跟原始的 interface 合并,使得扩展外部类型非常方便。

举例来说,Web 网页开发经常会对`windows`对象和`document`对象添加自定义属性,但是 TypeScript 会报错,因为原始定义没有这些属性。解决方法就是把自定义属性写成 interface,合并进原始定义。
举例来说,Web 网页开发经常会对`window`对象和`document`对象添加自定义属性,但是 TypeScript 会报错,因为原始定义没有这些属性。解决方法就是把自定义属性写成 interface,合并进原始定义。

```typescript
interface Document {
Expand Down

0 comments on commit 0299aa9

Please sign in to comment.