In typescript, when you have an exported variable that uses a private type from an external module, you may run into issues because private types are not accessible outside of their module.

answers for exported variable that uses a private type from an external module:

To fix exported variable using private type from external module, you can consider a few approaches:

Fix steps

just declare the type, for example:

in external lib has code like below:

interface privateProperty {
  name: string;
}
export const config = {
  propName: {} as privateProperty
}

in your code

// this config['propName'] contains non-exported type/interface
import { config } from 'external-lib';

// declare new type from private property
type Y = config['propName']; // or typeof config['propName']
// declare new type that extends Y
export interface X extends Y {}
// apply interface X which contains Private Type Name
export const yourVariable = {} as X;

Conclusion

done. now the problem fixed

result

before

error

after

success