企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## declare module `declare module`也可用于在一个文件中一次性声明多个模块的类型[27](https://github.com/xcatliu/typescript-tutorial/tree/master/examples/declaration-files/27-multiple-declare-module): ``` // types/foo-bar.d.ts declare module 'foo' { export interface Foo { foo: string; } } declare module 'bar' { export function bar(): string; } ``` ``` // src/index.ts import { Foo } from 'foo'; import * as bar from 'bar'; let f: Foo; bar.bar(); ``` ## 声明文件中的依赖:三斜线指令 ``` // types/jquery-plugin/index.d.ts /// <reference types="jquery" /> declare function foo(options: JQuery.AjaxSettings): string; ``` ## 拆分声明文件 ``` // node_modules/@types/jquery/index.d.ts /// <reference types="sizzle" /> /// <reference path="JQueryStatic.d.ts" /> /// <reference path="JQuery.d.ts" /> /// <reference path="misc.d.ts" /> /// <reference path="legacy.d.ts" /> export = jQuery; ``` > types 用于声明对另一个库的依赖 > path 用于声明对另一个文件的依赖。