我正在尝试扩充types中的convict。当前,定义使用以下命令导出convict
:
namespace convict { ... }
interface convict { ... }
declare var convict: convict;
export = convict;
因此,我扩展了界面(在./types/convict/index.d.ts
中):
declare module 'convict' {
interface convict {
<T>(
config: convict.Schema<T> | string,
options?: { env: Record<string, string> }
): convict.Config<T>;
}
}
但是,在导入默认导出convict
时未拾取此接口。看来这是由export = convict
和declare var convict: convict
引起的。但是我可以直接导入增强接口:
// Default import fails - same interface as @types/convict
import convict from 'convict';
// Import interface directly is ok - convict interface is augmented
import { convict } from 'convict';
任何人都可以帮助我理解为什么export = convict
和declare var convict: convict
忽略增强接口吗?