Packaging uncompiled TypeScript code in a NPM module

Writing a node module in TypeScript and publishing it in its original form on NPM is not as straightforward as it should be, because this system was originaly designed for Javascript modules only.

The challenge is to properly package the typing information from your TypeScript code, that may get lost in the process if you don’t do it the right way.
That’s why I decided to put together the information I gathered while addressing the issue.

In this tutorial, I will explain the easiest way to package some TypeScript code into a node module, preserving all the typing information from the source code, without using any third-party tool.

You can download the full sample project on my GitHub repo. It is a working example of a TypeScript package.
Continue reading