If you publish a TypeScript library — especially a paid SDK — you want two things that look like they conflict. Consumers should get excellent typings: autocomplete, jump-to-definition on the public API, no any leaking into their project. They should not get a readable copy of your implementation. Those goals do not conflict if you treat .d.ts as the product surface and the runtime JavaScript as a different artifact.
The typings describe what can be called. The published JavaScript is how it runs. You can ship the first in the clear and make the second much harder to casually copy. You cannot make the runtime secret — consumers have to execute it — and you should not use this technique to hide malware or to dodge a package registry's rules.…