<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## UMD 庫 既可以通過`<script>`標簽引入,又可以通過`import`導入的庫,稱為 UMD 庫 ts 提供了一個新語法`export as namespace` ## export as namespace ``` // types/foo/index.d.ts export as namespace foo; export = foo; declare function foo(): string; declare namespace foo { const bar: number; } ``` 也可與`export default` 一起使用 ``` export as namespace foo; export default foo; declare function foo(): string; declare namespace foo { const bar: number; } ``` ## 直接擴展全局變量§ ``` interface String { prependHello(): string; } // 'foo'.prependHello(); ``` 通過聲明合并,使用`interface String`即可給`String`添加屬性或方法。 ## 在 npm 包或 UMD 庫中擴展全局變量 對于 npm 包或 UMD 庫,如果導入此庫之后會擴展全局變量,則需要使用另一種語法在聲明文件中擴展全局變量的類型,那就是`declare global`。 #### `declare global`[§](https://ts.xcatliu.com/basics/declaration-files.html#declare-global) 使用`declare global`可以在 npm 包或者 UMD 庫的聲明文件中擴展全局變量的類型[25](https://github.com/xcatliu/typescript-tutorial/tree/master/examples/declaration-files/25-declare-global): ``` // types/foo/index.d.ts declare global { interface String { prependHello(): string; } } export {}; ``` ``` // src/index.ts 'bar'.prependHello(); ``` 注意即使此聲明文件不需要導出任何東西,仍然需要導出一個空對象,用來告訴編譯器這是一個模塊的聲明文件,而不是一個全局變量的聲明文件。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看