I have an working solution for this at - https://stackoverflow.com/a/79436047/18230058.
We can retrive any version from package.json by extracting the value during build time. this requires no changes from tsconfig & can be easily done with a simple file fetch and file update script. Please refer above link for complete solution.