AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[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 用于声明对另一个文件的依赖。