In the process of developing a module (module1), I have defined the following interface type:
interface ModuleOneInterface {
keyOne: customInterface;
keyTwo: customInterface;
keyThree: customInterface;
}
Now, as I work on another module (module2), I need to use the above interface as a prop in one of its components. However, since the interface is not exported from module1, I am unable to import it into module2. I attempted to create a new interface that represents the type needed in module2. Here is what I came up with:
export interface ModuleTwoInterface {
//This interface accommodates the module one interface
module2KeyOne: Record<string, customInterface>;
module2KeyTwo: string;
}
Unfortunately, this resulted in the following error:
TS2345: Argument of type 'ModuleOneInterface' is not assignable to parameter
of type 'Record<string, customInterface>'.
I also tried an alternative solution, but it didn't solve the issue either:
interface moduleTwoSubInterface {
[key: string]: customInterface;
}
export interface ModuleTwoInterface {
// This interface also aims to accommodate the module one interface
module2KeyOne: moduleTwoSubInterface;
module2KeyTwo: string;
}
If anyone has any insights or suggestions, they would be greatly appreciated.