Disclaimer: I’m not describing the migration process step-by-step or TypeScript itself in this article. You can find many resources on that online, including official TS docs.
In one of our projects at Yumasoft we needed to replace npm library’s implementation with a custom one. This was needed because one of the components we use created their own version (fork) of this npm package (the component uses this library internally). In order to make the component working correctly, we had to use the component’s authors version of the library, instead of using the original npm package. It turned out to not be an easy task, but finally we found a nice and easy solution.