I am currently working on enhancing the types of convict. The current definitions export convict
using the following:
namespace convict { ... }
interface convict { ... }
declare var convict: convict;
export = convict;
To augment the interface, I have made changes in ./types/convict/index.d.ts
:
declare module 'convict' {
interface convict {
<T>(
config: convict.Schema<T> | string,
options?: { env: Record<string, string> }
): convict.Config<T>;
}
}
However, when importing the default export convict
, the augmented interface is not recognized. It seems that this issue is caused by the presence of export = convict
and declare var convict: convict
. Nonetheless, importing the augmented interface directly works fine:
// 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';
Could someone assist me in comprehending why export = convict
and declare var convict: convict
are not recognizing the augmented interface?