0
In Typescript 2.2我试图定义一个模块(HapiJS),它有各种插件选项。当Typescript定义跨多个文件拆分时,使用插件修改模块
我重构的核心代码分成多个文件.d.ts然后导入并使用下述模式(as seen here)再出口它们全部来自index.d.ts:
export * from './hapi/connection';
export * from './hapi/reply';
export * from './hapi/request';
export * from './hapi/response';
export * from './hapi/route';
export * from './hapi/server_views';
export * from './hapi/server';
在一个单独的模块,它扩展了他们as seen here:
import * as hapi from 'hapi';
declare module 'hapi' {
interface IFileHandler {
/** path - a path string or function as described above (required). */
path: string | IRequestHandler<string>;
...
}
// Extending hapi core:
interface IRouteConfiguration {
file?: string | IRequestHandler<string> | IFileHandler;
然而,当我这样做的所有引用IRequestHandler
上面的错误:“无法找到名为‘IRequestHandler’。”如果所有的hapi代码都被移回到一个巨大的index.d.ts中,那么它就像预期的那样工作。有没有办法实现这个使用多个hapi定义文件?