Your first Typescript Package on NPM (Part 1/2)

Arbaz Ajaz
2 min readNov 4, 2020

--

Setting up using TSDX….

Yesterday I was working on React.js Project and I was using Typescript and I thought wouldn’t it be nice if I could create and publish my own packages (written in typescript) on npmjs.org.

TLDR: I found out about this package tsdx. It sets up the environment so you can start writing your own npm package right away!

All you have to do is run the following command to set up your package.

npx tsdx create <package-title>
// replace <package-title> with the package name that is unique.

Please, pick a name/title/package-title that is unique, you can easily check that by going to the following url:

https://www.npmjs.com/package/<package-title>
// replace the <package-title> with the name/title you'd like to check if it's available.

If the name is available, you’ll see a 404 page somewhat like this:

That’s it, use this name for your package.

Next, it will ask you to pick a template, as of now, it only supports basic | react | react with story book.

I picked the basic template because I want to create a utility library with helper functions I’ll be needing in future.

After it is done with everything, you can simply open up the project in your favorite code-editor (I use VSCode.)

Finally, when you’re done building the library, I’ll be writing about how we can test our code using jest. We’re all set for publishing this sweet little package.

I’ll write a follow up article on how to publish your newly created package and I’ll provide the link below!

Part 2: https://arbaz5256.medium.com/your-first-typescript-package-on-npm-part-2-2-dcaf422bed2

--

--

Arbaz Ajaz
Arbaz Ajaz

Written by Arbaz Ajaz

Arbaz is a MERN Stack developer, aiming to make learning programming accessible and straight forward

No responses yet