In the process of developing a TypeScript library package called 'MyPkg,' I have created some classes (such as 'MyPkgClass') located in a specific sub-directory [e.g., src/path/to/mypkg] with essential functionality.
The goal is for another package, named 'OtherPkg,' to extend 'MyPkgClass' and add any additional features as needed. This allows me to provide basic features that I can modify or enhance in the future.
During local testing using 'npm link' in 'OtherPkg,' I realized that importing 'MyPkgClass' was problematic:
import MyPkgClass from “MyPkg/bin/<path>/<to>/MyPkgClass”
This method would restrict my ability to move or rename the file/class later on, which is not ideal. While I could create a different class at a fixed location under 'bin' and extend it from 'MyPkgClass' to prevent breaking 'OtherPkg,' this approach seems like poor design.
What is the correct way to expose 'MyPkgClass'? Should I re-export it from Index.ts of MyPkg? Or should I export 'MyPkgClass' as a type?
I am seeking guidance on standard TypeScript documentation or examples for assistance as a newcomer facing these challenges. I have attempted to search TypeScript documentation without success, possibly due to using incorrect search terms.